2013-08-28 17 views
0

我在htacces這些瓦萊斯文件這一切工作正常,除了當我嘗試從https回去HTTP我曾嘗試沒有成功各地交換的規則,任何幫助將是要命的htaccess到http

我已經嘗試過所有sujestion但仍沒有suucess,所以也許我需要向你們展示整個事情。

仍然不會從https回到http,這裏是整個事情 我是否按錯誤順序得到了規則? IM丟失

<ifModule mod_rewrite.c> 
RewriteEngine on 
# For Sales: 

RewriteRule ^shop/sales/?$ sales.php 
# For the primary categories: 

RewriteRule ^shop/([A-Z-Aa-z\+]+)/?$ shop.php?type=$1 
# For specific products: 

RewriteRule ^browse/([A-Za-z\+]+)/([A-Za-z\+\-]+)/([0-9]+)$ browse.php?type=$1&category=$2&id=$3 
#For https pages: 

#RewriteCond %{HTTPS} on 
#RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L=301] 

#RewriteCond %{HTTPS} off 
#RewriteRule ^(checkout\.php|final\.php|admin/(.*))$ https://{HTTP_HOST}/$1[R=301,L] 


RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?$1 [L,QSA] 

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC] 
RewriteRule^/%1 [R=301,L] 
</ifModule> 
+0

如果第二條規則中沒有無效標誌,將會創建一個無限循環。 – Sumurai8

回答

0

我沒能測試的規則,但我認爲你需要更改下列內容:

在你的標誌被附加到第二個參數的第一個規則。這應該會產生一個內部錯誤。你的第二條規則會將所有url重寫爲它們的http等價物,從而形成無限循環。您需要確保它不符合您希望在https中使用的網址。你可以用%{REQUEST_URI}和否定(!)來做到這一點。據我所知,L=301也是一個無效標誌。你可能是想讓它變成R=301

RewriteCond %{HTTPS} off 
RewriteRule ^(checkout\.php|final\.php|admin/(.*))$ https://{HTTP_HOST}/$1 [R,L] 

RewriteCond %{HTTPS} on 
RewriteCond %{REQUEST_URI} !/(checkout\.php|final\.php|admin/(.*))$ 
RewriteRule ^http://%{HTTP_HOST}%{REQUEST_URI} [R,L] 

最後但並非最不重要的一個建議的話。不要測試你的.htaccess永久重定向,直到一切按預期工作。瀏覽器將緩存永久重定向,而不是進一步嘗試使你的.htaccess如你所願。

相關問題