我正在尝试让我的.htaccess文件只将特定的页面/文件夹重定向到https,如果它不是需要加密的页面,那么它应该射杀用户的http页面。此外,我希望能够列出某些文件夹,可以是HTTP或HTTPS
这是我尝试用自己写的东西。但似乎并不能完全正确地工作。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteCond $1 ^(myaccount|payment\.html)
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]
RewriteCond %{SERVER_PORT} 443
RewriteCond $1 !^(myaccount|payment\.html)
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
</IfModule>发布于 2011-07-05 05:21:23
您正在检查RewriteCond模式中的文字$1。它应该是:
RewriteCond %{REQUEST_URI} ...stuff to match against here...发布于 2011-07-05 05:23:54
这应该可以做你想要的事情。
RewriteCond %{SERVER_PORT} 443 [NC]
RewriteCond %{REQUEST_URI} !^/(myaccount|payment)\.html [NC]
RewriteRule . http://www.domain.com/%{REQUEST_URI}/ [R=301,L]https://stackoverflow.com/questions/6576142
复制相似问题