我的.htaccess
中有这个Options +FollowSymlinks
RewriteEngine On
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L=301]
RewriteCond %{HTTP_HOST} ^www\.clipboards\.com [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L=301]
这些条件正常,只有一个例外。 如果我来自http(非ssl),它会将index.php? route 添加到我的网址,然后再将其发送到https。如果我直接来自https就不是这种情况,在这种情况下它可以正常工作。有人可以帮我弄这个吗。感谢
答案 0 :(得分:1)
您应该将重定向放在顶部,并且可以结合最底层的2条规则。另请注意,您的语法[R,L=301]
无效,应为[R=301,L]
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]