Php .htaccess针对别名域的http到https重定向
我是,进入了一个场景,其中两个具有多个子域的域仅托管在一个站点上(文件位于一个目录中,但两个域指向它),即 www.abc.com(是主要网站) www.abc.ca(是别名为上述网站的web空间的网站) 现在,我想在.htaccess中添加一个规则,将它们从http://重定向到https://这不起作用,因为它会在那里导致循环或无法正确重定向Php .htaccess针对别名域的http到https重定向,php,apache,.htaccess,redirect,https,Php,Apache,.htaccess,Redirect,Https,我是,进入了一个场景,其中两个具有多个子域的域仅托管在一个站点上(文件位于一个目录中,但两个域指向它),即 www.abc.com(是主要网站) www.abc.ca(是别名为上述网站的web空间的网站) 现在,我想在.htaccess中添加一个规则,将它们从http://重定向到https://这不起作用,因为它会在那里导致循环或无法正确重定向 RewriteCond %{HTTPS} !=on RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
需要帮助来解决此问题。是目前推荐的解决方案,请尝试以下方法:
<VirtualHost *:80>
ServerName example.org
ServerAlias *.example.org
Redirect / https://example.org/
</VirtualHost>
<VirtualHost *:443>
ServerName example.org
ServerAlias *.example.org
ServerName example.org
ServerAlias*.example.org
重定向/https://example.org/
ServerName example.org
ServerAlias*.example.org
是目前推荐的解决方案,请尝试以下方法:
<VirtualHost *:80>
ServerName example.org
ServerAlias *.example.org
Redirect / https://example.org/
</VirtualHost>
<VirtualHost *:443>
ServerName example.org
ServerAlias *.example.org
ServerName example.org
ServerAlias*.example.org
重定向/https://example.org/
ServerName example.org
ServerAlias*.example.org
下面的答案对你有用吗?下面的答案对你有用吗?