2
我想重定向所有non-www
和所有non-https
到https://www
URL。错误的重定向从.htaccess
我有一个包含以下代码的.htaccess:
RewriteEngine On
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
即工作的根路径:
OK https://www.mywebsite.com => https://www.mywebsite.com
OK http://mywebsite.com => https://www.mywebsite.com
OK https://mywebsite.com => https://www.mywebsite.com
OK http://www.mywebsite.com => https://www.mywebsite.com
但有(种)的一个错误,当我尝试去在子文件夹中:
OK https://www.mywebsite.com/tmp => https://www.mywebsite.com/tmp
KO https://mywebsite.com/tmp => https://www.mywebsite.com/tmp/tmp
KO http://www.mywebsite.com/tmp => https://www.mywebsite.com/tmp/tmp
KO http://mywebsite.com/tmp => https://www.mywebsite.com/tmp/tmp
正如你所看到的,子文件夹被再次追加,它会给出一个404错误。
如何修复我的.htaccess规则以获得预期的重定向?
非常感谢
非常感谢它的魅力! – void