2014-10-10 44 views
1

我使用codeigniter和我使用重定向所有網址https。現在我只想將一個頁面(https://www.example.com/campaign/PPRTasshs-dhshs_fd5656dfhdh/web/surf)重定向到http。重定向只有一個頁面http htaccess

我在那裏得到了很多答案。但我無法正確實施。每次我收到錯誤「這個網頁有一個重定向循環」。

我的htaccess

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/

RewriteCond %{HTTPS} off 
# First rewrite to HTTPS: 
# the subsequent rule will catch it. 

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
# Now, rewrite any request to the wrong domain to use www. 

RewriteCond %{SERVER_PORT} 443 
RewriteCond $1 (web\/surf|surf) 
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

RewriteCond %{HTTP_HOST} !^www\. 
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]  
RewriteRule ^about-us/[L,R=301] 

Options -Indexes 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php/$1 [L] 
</IfModule> 

<IfModule !mod_rewrite.c> 
ErrorDocument 404 /index.php 
</IfModule> 

鏈接上,這樣我試過,但不是爲我工作。

Codeigniter: Check and force one page to https://

Redirect single page http to https

在此先感謝

回答

1

您必須在https重定向時更改條件,並檢查https://www重定向時的額外條件。請嘗試以下代碼。這可能會幫助你。

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/


RewriteCond %{HTTPS} off 
# First rewrite to HTTPS: 
# the subsequent rule will catch it. 

**RewriteCond $1 !(web\/surf|surf)** 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
# Now, rewrite any request to the wrong domain to use www. 

RewriteCond %{SERVER_PORT} 443 
RewriteCond $1 (web\/surf|surf) 
RewriteRule ^(.*)$ http://www.traffictraject.com/$1 [R=301,L] 

RewriteCond %{HTTP_HOST} !^www\. 
**RewriteCond $1 !(web\/surf|surf)** 
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

RewriteRule ^about-us/[L,R=301] 

Options -Indexes 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php/$1 [L] 
</IfModule> 

<IfModule !mod_rewrite.c> 
ErrorDocument 404 /index.php 
</IfModule> 
+0

謝謝@paresh-thummar ..它的工作..再次感謝 – user1673762 2014-10-11 10:44:52

0

聽起來頁面的SSL和非SSL版本重定向來回,這就是爲什麼你會得到重定向循環。您需要爲重定向添加額外的條件。沒有檢查,但它應該工作。

http - >https重定向把這個條件太

RewriteCond %{REQUEST_URI} !/campaign/PPRTasshs-dhshs_fd5656dfhdh/web/surf 

這應該防止重定向循環

重定向HTTPS - > HTTP檢查HTTPS條件是on並檢查網址通過移除!匹配

RewriteCond %{REQUEST_URI} /campaign/PPRTasshs-dhshs_fd5656dfhdh/web/surf 

然後重定向到http

0

我希望這會有所幫助。

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/

    RewriteCond %{HTTPS} off 
    # First rewrite to HTTPS: 
    # the subsequent rule will catch it. 

    RewriteCond %{SERVER_PORT} 80 
    RewriteCond %{REQUEST_URI} !campaign/PPRTasshs-dhshs_fd5656dfhdh/web/surf 
    RewriteRule ^(.*)$ https://www.yourdomain.com%{REQUEST_URI} [L,R=301] 

    Options -Indexes 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ /index.php/$1 [L] 

    RewriteRule ^about-us/[L,R=301] 
</IfModule> 

<IfModule !mod_rewrite.c> 
    ErrorDocument 404 /index.php 
</IfModule> 
相關問題