2017-02-11 32 views
0

我有一個.htaccess文件見下文的.htaccess重定向,除了一個特定的請求

Options +FollowSymLinks +ExecCGI 

<IfModule mod_rewrite.c> 

#Every www request to non-www 
RewriteEngine On  
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] 
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L] 

#every http request in amdinistrator folder redirect to https 
RewriteCond %{HTTPS} off 
RewriteCond %{REQUEST_URI} ^/administrator 
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] 

#every https request except ftp and one specific request redirect to http 
RewriteCond %{HTTPS} =on 
RewriteCond %{REQUEST_URI} !^/ftp 
RewriteCond %{REQUEST_URI} !=/preview/index.php?request_type=preview_engime 
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [L,R=301] 

#redirect which request contains PUBLIC_AJAX_ENGIME 
RewriteRule ^(.*)PUBLIC_AJAX_ENGIME(.*)$ index.php?request_type=ajax_engime [L] 

#files and directories 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule . index.php [L] 

</IfModule> 

我不想在這種情況下重定向:

https://somewebsite.domain/preview/index.php?request_type=preview_engime

但這裏系統重定向

http://somewebsite.domain/index.php?request_type=preview_engime

an我不明白爲什麼。

謝謝! FF

回答

0

這是因爲你的url包含查詢字符串。您無法使用REQUEST_URI變量與QueryString匹配。您需要匹配THE_REQUEST變量。與此更換你的RewriteCond:

RewriteCond %{THE_REQUEST} !/index\.php\?request_type=preview_engime [NC] 
+0

這幾乎是好...現在請求被重定向到這裏: HTTP:// somewebsite.domain /預覽/ index.php的request_type = preview_engime 但我需要HTTPS在這種情況下。 – Fferlen

相關問題