如何使用扩展斜杠重定向到HTTPS

时间:2017-11-21 16:15:51

标签: apache .htaccess redirect

我在.htaccess中使用此代码

RewriteCond %{HTTP_HOST} !^www\.    
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI}$1 [R=301,L]     
RewriteCond %{HTTPS} off      
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}$1 

将所有请求重定向到https,例如 example.com 会重定向到 https://www.example.com 但我的问题是,当网址如下示例时.com / hello http://www.example.com/hello 它重定向但是 https 但是会导致404错误,即使它重新定向到网址也是如此将example.com或example.com/hello添加到https://www.example.comhttps://www.example.com/hello,没有404错误。

0 个答案:

没有答案