2014-02-27 32 views
0

我已經使用下面的代碼正確啓用了HTTPS重定向。 訪問其中一個HTTPS頁面後,所有其他網址都繼承了以前的HTTPS。我如何強制所有其他頁面到HTTP?使用htaccess將http重定向到https for Wordpress?

# BEGIN WordPress 
<IfModule mod_rewrite.c> 

RewriteEngine On 
RewriteCond %{HTTPS} !on 
RewriteCond %{REQUEST_URI} ^(/checkout|/downloads|/all-products) 
RewriteRule ^(.*)$ https://websitename.com/$1 [R,L] 

RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 
# END WordPress 

回答

1

您可以使用:

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/

RewriteCond %{HTTPS} off 
RewriteCond %{REQUEST_URI} ^/(checkout|downloads|all-products) 
RewriteRule ^(.*)$ https://websitename.com/$1 [R=301,L,NE] 

RewriteCond %{HTTPS} on 
RewriteCond %{REQUEST_URI} !^/(checkout|downloads|all-products) 
RewriteRule ^(.*)$ http://websitename.com/$1 [R=301,L,NE] 

RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 
# END WordPress 
+0

謝謝!但是,我收到了重定向到websitename.com/index.php。我有沒有這個組織不正確? – user3325858

+0

您爲哪個網址重定向到'websitename.com/index.php'? – anubhava

+0

由於某種原因,每個/(checkout | downloads | all-products)都會重定向到索引。 – user3325858

相關問題