Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php .htaccess针对别名域的http到https重定向_Php_Apache_.htaccess_Redirect_Https - Fatal编程技术网

Php .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,

我是,进入了一个场景,其中两个具有多个子域的域仅托管在一个站点上(文件位于一个目录中,但两个域指向它),即

www.abc.com(是主要网站) www.abc.ca(是别名为上述网站的web空间的网站)

现在,我想在.htaccess中添加一个规则,将它们从http://重定向到https://这不起作用,因为它会在那里导致循环或无法正确重定向

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

下面的答案对你有用吗?下面的答案对你有用吗?