2013-08-28 27 views
0

這是我的htaccess代碼不同的是:重定向到SSL時,URL匹配的特定標準

RewriteOptions inherit 
RewriteEngine on 

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L] 


AddDefaultCharset utf-8 
RewriteCond %{HTTP:Authorization} ^(.*) 
RewriteRule ^(.*) - [E=HTTP_CGI_AUTHORIZATION:%1] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([0-9A-Za-z]{12})(\/.+|\.html?|$) /cgi-bin/index_dl.cgi?op=download1&id=$1&fname=$2 [L] 
RewriteRule ^ot:(.*)    /cgi-bin/index_dl.cgi?op=download1&otid=$1 [L,B] 

目前,它被重定向一切SSL。不過,我希望它這樣,當文件名符合此條件

RewriteRule ^([0-9A-Za-z]{12})(\/.+|\.html?|$) /cgi-bin/index_dl.cgi?op=download1&id=$1&fname=$2 [L] 

它需要只允許非SSL

我GOOGLE和GOOGLE了,但我無法弄清楚如何做到這一點。

任何幫助表示讚賞:)

回答

0

在,做重定向規則,只需添加一個排除條件:

RewriteCond %{HTTPS} off 
RewriteCond %{REQUEST_URI} !^/([0-9A-Za-z]{12})(\/.+|\.html?|$) 
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L] 

,或者您可以使用規則的模式結合起來:

RewriteCond %{HTTPS} off 
RewriteRule !^([0-9A-Za-z]{12})(\/.+|\.html?|$) https://www.domain.com%{REQUEST_URI} [R=301,L] 

編輯:

要將該模式的SSL請求重定向到非SSL,請在其他重定向規則的下方添加此權限:

RewriteCond %{HTTPS} on 
RewriteRule ^([0-9A-Za-z]{12})(\/.+|\.html?|$) https://www.domain.com%{REQUEST_URI} [R=301,L] 
+0

謝謝!差不多了。我需要它,所以它不能在該排除中使用SSL。如果使用SSL,則需要重定向到非SSL。但僅限於此標準。 –

+0

@papa_face幾乎相同的東西,請參閱編輯 –

+0

令人驚歎!謝謝 :) –