【发布时间】:2019-10-03 16:02:10
【问题描述】:
我已经设法为 www 和非 www(纯 http)和 https 创建了有效的重定向,但是当它们一起使用时,它不再起作用了。我有四个域,希望每个域都重定向到一个基域,然后添加 url 参数。
现在尝试不同变体时的当前结果:
www.example.fi -> redirects me to https://example.se/?lang=fi. OK
http://example.fi -> redirects me to https://example.se/?lang=fi OK
https://example.fi -> redirects me to https://example.se/?lang=fi OK
https://www.example.fi -> redirects me to https://example.se without the lang parameters. WRONG. It should take me to the same place as the other.
这是我的 http 虚拟主机:
<VirtualHost *:80>
ServerName www.example.fi
ServerAlias example.fi
DocumentRoot /var/www/html/dir
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Redirect permanent / https://example.se/?lang=fi
</VirtualHost>
这是我的 https:
<VirtualHost *:443>
ServerName www.example.fi
ServerAlias example.fi
DocumentRoot /var/www/html/dir
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /home/user/example.fi.pem
SSLCertificateKeyFile /home/user/example.fi.key
SSLCACertificateFile /home/user/intermediate.pem
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.fi$ [NC]
RewriteRule ^ https://example.se%{REQUEST_URI}/\?lang=fi [R=301,L]
如您所见,我希望不同的语言域使用语言参数指向 SE 域。
如何修改我的代码,使其与 https、http 和 www 的所有可能变体匹配?
【问题讨论】:
标签: apache ssl url-rewriting virtualhost