2015-02-24 68 views
1

我想重定向我的所有頁面,使他們使用HTTPS協議,除了一個路徑。我確實找到了以下頁面(mod_rewrite redirect all to https except one file),但提供的解決方案對我無效。我也嘗試過其他解決方案,都無濟於事。國防部重寫全部重定向到https除了一個文件

這裏是我當前的代碼:

Options -Indexes 
RewriteEngine On 

# do nothing for my-awesome-path.php 
RewriteRule ^keg-collars-studio\.php$ - [L] 

RewriteCond %{HTTPS} off 
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} 

RewriteRule ^(.*)\.html$ $1\.php [QSA,L] 

我已經編輯我的職務與確切的內容和路徑。任何幫助是極大的讚賞。

+0

的路徑是mysite.com/my-awesome-path.php – 2015-02-24 10:39:04

+0

當然,我已經編輯我的職務。 – 2015-02-24 11:05:03

回答

2

試試這個的.htaccess:

Options -Indexes 
RewriteEngine On 

# Turn SSL off everything but payments 
RewriteCond %{THE_REQUEST} !/keg-collars-studio\.php [NC] 
RewriteCond %{HTTPS} off 
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=302] 

RewriteRule ^(.+?)\.html$ $1.php [NC,L] 
+0

仍然將我重定向到https:http://www.kegcollars.net/keg-collars-studio.html – 2015-02-24 13:32:23

+0

現在看起來工作正常。我已經刪除了這一行上的^和https之間的空格:RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R = 302] – 2015-02-24 13:57:54

+1

很高興知道它適合你。 – anubhava 2015-02-24 14:09:56