2015-10-07 78 views
2

我有我的網站運行在SSL上,但我添加了一個遊戲部分,使用閃存中的第三方遊戲。當我啓用SSL時,它停止工作。我很奇怪,如果我只能禁用該網址中包含「/ game /」的特定頁面上的SSL,以便遊戲正常運行。如何禁用SSL,如果一個頁面url包含一個特定的字

我試圖從insternet這個代碼在我的.htaccess文件,但不工作:

RewriteCond %{HTTPS} off 
RewriteRule ^game^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

編輯:

我試着回答提示:

RewriteEngine On 
RewriteCond %{HTTPS} On [NC] 
RewriteRule ^game http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NC] 

它的工作原理,但是當我去包含單詞「遊戲」的頁面將其他頁面也變成「http」,其他頁面變成使用「http」而不是「https」

然後我嘗試這樣的:

RewriteEngine On 
RewriteCond %{HTTPS} !=on 
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
RewriteCond %{HTTPS} On [NC] 
RewriteRule ^game http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NC] 

這它開始給我的消息「頁面沒有正確重定向」當我去「遊戲」頁面的URL。

我只希望「遊戲」頁面使用「http」。

編輯兩個:完整的.htaccess文件

<IfModule mod_rewrite.c> 
    Options +FollowSymLinks 
    RewriteEngine On 
    RewriteCond %{HTTPS} !=on 
    RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

    # Get rid of index.php 
    RewriteCond %{REQUEST_URI} /index\.php 
    RewriteRule (.*) index.php?rewrite=2 [L,QSA] 

    # Rewrite all directory-looking urls 
    RewriteCond %{REQUEST_URI} /$ 
    RewriteRule (.*) index.php?rewrite=1 [L,QSA] 

    # Try to route missing files 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} public\/ [OR] 
    RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$ 
    RewriteRule . - [L] 

    # If the file doesn't exist, rewrite to index 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA] 

</IfModule> 

# sends requests /index.php/path/to/module/ to "index.php" 
# AcceptPathInfo On 

# @todo This may not be effective in some cases 
FileETag Size 

<IfModule mod_deflate.c> 
    AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript 
</IfModule> 

需要幫助。如果發現任何重複,請告知我,但我找不到任何人。 謝謝。

+0

如果您在.htaccess文章中有更多規則,請在此完成.htaccess。 – anubhava

+0

我添加了完整的代碼。 – M3Dev

回答

0

這應該是你完全的.htaccess:

<IfModule mod_rewrite.c> 
    Options +FollowSymLinks 
    RewriteEngine On 

    # except for /game/ enforce https 
    RewriteCond %{HTTPS} off 
    RewriteCond %{THE_REQUEST} !/game/ [NC] 
    RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

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

    # Get rid of index.php 
    RewriteCond %{REQUEST_URI} /index\.php 
    RewriteRule (.*) index.php?rewrite=2 [L,QSA] 

    # Try to route missing files 
    RewriteCond %{REQUEST_FILENAME} public [OR] 
    RewriteCond %{REQUEST_URI} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$ 
    RewriteRule . - [L] 

    # If the file doesn't exist, rewrite to index 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA] 

</IfModule> 

確保測試這種變化之前,清除瀏覽器緩存。

+0

它給你我的錯誤「ERR_TOO_MANY_REDIRECTS」與你相同的htaccess文件。 – M3Dev

+0

這意味着你仍然在瀏覽器中擁有舊的緩存。在停用緩存的Chrome開發工具中進行測試。然後在'Network'選項卡中監控您看到301/302重定向的URL。順便說一句'/遊戲/'也有一個.htaccess? – anubhava

+0

我嘗試了你的建議,使用禁用緩存選項以及私人瀏覽也我使用zend應用程序中沒有模塊中的htaccess文件,遊戲是一個模塊。根目錄中只有一個htaccess文件。 – M3Dev