2011-07-04 152 views
1

我試圖讓我的.htaccess文件只重定向到https的某些網頁/文件夾,如果它不是需要加密的網頁,那麼它應該向用戶發送http頁面。此外,我希望能夠列出可以是HTTP或HTTPS的某些文件夾Htaccess 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> 

回答

1

您正在檢查RewriteCond模式中的文字$1。它應該是:

RewriteCond %{REQUEST_URI} ...stuff to match against here... 
0

這應該做你想做的。

RewriteCond %{SERVER_PORT} 443 [NC] 
RewriteCond %{REQUEST_URI} !^/(myaccount|payment)\.html [NC] 
RewriteRule . http://www.domain.com/%{REQUEST_URI}/ [R=301,L]