2017-06-13 94 views
1

我有一個網站(可以說website.com),使用的.htaccess,內容如下:重定向HTTP到HTTPS例外

ErrorDocument 403 /index.php 
Options -Indexes 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 
RewriteRule ^.*$ index.php [NC,L] 

我需要HTTP重定向到https。對於這一點,我在虛擬主機設置中加入這一行:

Redirect permanent/https://website.com/ 

結果,它重定向所有到HTTPS

我的問題是我需要的例外添加到我的重定向 對於離。這條路線http://website.com/folder/test/ *後的所有流量應該被路由到HTTP

請幫 感謝

+0

具有#2類似的問題。 [請參閱此鏈接](https://stackoverflow.com/questions/26426893/htaccess-redirect-to-https-except-a-few-urls) –

+1

可能重複[從https重定向到http,除了某些URI ](https://stackoverflow.com/questions/16065065/redirecting-from-https-to-http-with-the-exception-of-some-uris) –

回答

0

的RewriteCond有助於在這種情況下

RewriteEngine On 

RewriteCond %{HTTP_HOST} !^www\. 
RewriteRule^https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 


# force http:// for selected URLs 
RewriteCond %{HTTPS} on 
RewriteCond %{THE_REQUEST} /subfolder/ [NC] 
RewriteRule^http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]