我有以下.htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.old_domain.de$
RewriteRule (.*) https://new_domain.de/$1 [R=301,L]问题是,规则似乎只正确地重定向了www.old_domain.de或domain.de,而没有重定向domain.de或old_domain.de (它跳到https:// automaticaly)。在第二种情况下,我得到以下错误:
SSL_ERROR_UNRECOGNIZED_NAME_ALERT
我已经尝试将https://和非www域重写到http://www中。但以某种方式没能达到想要的结果。可能我错过了一些重要的事情。
在我的新域的.htaccess上,https://强制可能有什么问题吗?
发布于 2018-10-18 13:06:31
要重定向domain.de或www.old_domain.de或domain.de或old_domain.de,请使用以下代码
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?old_domain\.de$ [NC]
RewriteRule (.*) https://new_domain.de/$1 [R=301,L]您的代码缺少了(www\.)?中的RewriteCond,这将使重写工作,无论它是否包含www。
您可以在链接上使用htaccess测试器进行相同的测试。
类似地,您应该为SSL (HTTPS)配置一个单独的虚拟主机。在该虚拟主机中,还需要复制上面的代码。
SSL在端口443上配置为侦听,因此在htaccess中搜索类似于下面代码的内容。
<VirtualHost *:443>
ServerName www.old_domain.de
ServerAlias old_domain.de
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/example/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/example/apache.key
</VirtualHost>如果仍然无法找到配置虚拟主机监听443的文件,则可以使用-S标志运行apache,如下所示
httpd -S or apachectl -S这将给出虚拟主机监听443的文件名,如下面的输出所示。
*:80 default server xxx.xxx.xxx.xxx (/etc/httpd/conf.d/eco.conf:1)
port 80 namevhost xxx.xxx.xxx.xxx (/etc/httpd/conf.d/eco.conf:1)
*:443 default server xxx.xxx.xxx.xxx (/etc/httpd/conf.d/ssl.conf:1)
port 443 namevhost xxx.xxx.xxx.xxx (/etc/httpd/conf.d/ssl.conf:1)例如,/etc/httpd/conf.d/ssl.conf是配置虚拟主机监听443的文件。
https://stackoverflow.com/questions/52871668
复制相似问题