2012-08-24 39 views
1

我想重定向幾個選擇頁面到HTTPS。我發現了很多例子,但它們似乎並不適用於我當前的htaccess文件中的內容。我目前的htaccess有.htaccess多個重寫的重定向

RewriteEngine On 
Options +FollowSymLinks 
# Redirect all other domains to the primary 
RewriteCond %{HTTP_HOST} ^(www\.?|)(domain1\.com|domain2\.com|domain3\.com|\.co)$ 
RewriteRule ^(.*)$ http://www.prefferreddomain.com/$1 [R=301,L] 
# Error Documents 
ErrorDocument 401 /errors/401.php 
ErrorDocument 403 /errors/403.php 
ErrorDocument 404 /errors/404.php 
#Cache Settings, etc. after this 

我這樣做目前在我的SEO的htaccess文件,因爲我們擁有多個域名(20+)。無論如何,我想要3頁重定向到HTTPS,但所有我嘗試過的例子沒有按預期工作。我不確定是否應該在當前位於htaccess文件中的重定向之前或之後放置它們。

應該重定向到https的頁面是logon.php & chat.php。所以我試了

RewriteEngine On 
Options +FollowSymLinks 

RewriteCond %{HTTPS} off 
RewriteCond %{REQUEST_URI} (logon.php) 
RewriteRule (.*) https://www.preferreddomain.com%{REQUEST_URI} 

RewriteCond %{HTTPS} off 
RewriteCond %{REQUEST_URI} (chats.php) 
RewriteRule (.*) https://www.preferreddomain.com%{REQUEST_URI} 

# Redirect all other domains to the primary 
RewriteCond %{HTTP_HOST} ^(www\.?|)(domain1\.com|domain2\.com|domain3\.com|\.co)$ 
RewriteRule ^(.*)$ http://www.prefferreddomain.com/$1 [R=301,L] 
# Error Documents 
ErrorDocument 401 /errors/401.php 
ErrorDocument 403 /errors/403.php 
ErrorDocument 404 /errors/404.php 
#Cache Settings, etc. after this 

但是這不起作用。有沒有人有任何指針。

回答

0

[R=301,L]添加到每個https://規則的末尾。如果沒有L,規則將URI標記爲重定向,但URI將繼續貫穿重寫引擎的其餘部分,並將與最後一條規則匹配。

+0

這就產生了一個奇怪的重定向URL,如「HTTPS://www.preferreddomain/~1089811.1135986/htdocs/~1089811.1135986/htdocs/~1089811.1135986/htdocs/~1089811.1135986/htdocs/~1089811.1135986/htdocs/~1089811.1135986/htdocs/ 〜1089811.1135986/htdocs中/〜1089811.1135986/htdocs中/〜1089811.1135986/htdocs中/〜1089811.1135986/htdocs中/〜1089811.1135986/htdocs中/〜1089811.1135986/htdocs中/〜1089811.1135986/htdocs中/〜1089811.1135986/htdocs中/〜1089811.1135986/htdocs中/〜1089811.1135986/htdocs中/ 〜1089811.1135986/htdocs中/〜1089811.1135986/htdocs中/〜1089811.1135986/htdocs中/〜1089811.1135986/htdocs中/ logon.php」 –

0

發現它沒有工作的原因是因爲我們的主機網絡解決方案使用SSL代理,所以任何檢測協議的服務器端都不起作用,並且通常會導致循環。