htaccess重定向到https://Example.com(不带WWW),仅在所有根文件(即http://Example.com/file1.php)上起作用,但对文件夹(即http://Example.com/folder1/ )没有任何作用。
) 有什么建议吗?RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://Example.com%{REQUEST_URI}
[L,R=301,NC]
RewriteCond %{HTTP_HOST} ^www.Example.com [NC]
RewriteRule (.*) https://Example.com%{REQUEST_URI}
[L,R=301,NC]
我还使用了以下命令,但其中一些命令不适用于文件夹:
RewriteCond %{HTTP_HOST} ^Example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.Example\.com$
RewriteRule ^folder1\/?(.*)$ "https\:\/\/Example\.com\/folder1\/$1" [R=301,L]
RewriteCond %{HTTP_HOST} ^Example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.Example\.com$
RewriteRule ^folder1\/$ "https\:\/\/Example\.com\/folder1\/" [R=301,L]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-SSL} off
RewriteCond %{HTTP_HOST} ^Example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.Example\.com$
RewriteRule ^(.*)$ "https\:\/\/Example\.com\/folder1$1" [R=301,L]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-SSL} off
RewriteCond %{HTTP_HOST} ^Example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.Example\.com$
RewriteRule ^folder1\/?$ "https\:\/\/Example\.com\/folder1" [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^folder1(/|$) https://Example.com/folder1%{REQUEST_URI} [NC,R,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^Example\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://Example.com/$1 [R,L]