Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
.htaccess 结合https的非www重定向_.htaccess_Https - Fatal编程技术网

.htaccess 结合https的非www重定向

.htaccess 结合https的非www重定向,.htaccess,https,.htaccess,Https,我需要2个重定向。第一个是任何不是https的请求都应该是https。第二个是任何非www都应该是www。下面,https一个有效,但第二个无效,并附加在原始url上。我需要两者协调工作 # Redirect non https to https RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} # redirect non www to www Rewri

我需要2个重定向。第一个是任何不是https的请求都应该是https。第二个是任何非www都应该是www。下面,https一个有效,但第二个无效,并附加在原始url上。我需要两者协调工作

# Redirect non https to https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

# redirect non www to www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
当两者都启用时,第二个将在url中复制http_主机两次


我需要的是mysite.com重定向到以及重定向到更新:这在清除缓存后起作用