.htaccess重定向,但一个特定请求除外

.htaccess重定向,但一个特定请求除外,.htaccess,redirect,.htaccess,Redirect,我有一个.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 h

我有一个.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>
Options+FollowSymLinks+ExecCGI
#对非www的每个www请求
重新启动发动机
重写条件%{HTTP_HOST}^www\.(.*)$[NC]
重写规则^(.*)$http://%1%{REQUEST_URI}[R=301,QSA,NC,L]
#amdinistrator文件夹中的每个http请求都重定向到https
重写条件%{HTTPS}关闭
RewriteCond%{REQUEST_URI}^/管理员
重写规则^(.*)$https://%{HTTP_HOST}/$1[R=301,L]
#除了ftp和一个特定请求,每个https请求都重定向到http
RewriteCond%{HTTPS}=on
重写cond%{REQUEST_URI}^/ftp
重写cond%{REQUEST_URI}=/preview/index.php?请求类型=preview\u engime
重写规则^(.*)$http://%{http_HOST}/$1[L,R=301]
#重定向哪个请求包含PUBLIC\u AJAX\u ENGIME
RewriteRule^(.*)PUBLIC_AJAX_ENGIME(.*)$index.php?请求类型=AJAX_ENGIME[L]
#文件和目录
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则。index.php[L]
在这种情况下,我不希望重定向:

但是系统在这里重定向

我不明白为什么

谢谢大家!!
FF

这是因为您的url包含查询字符串。您无法使用REQUEST\u URI变量与QueryString进行匹配。您需要匹配_请求变量。将“重写条件”替换为以下内容:

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

它几乎是好的。。。现在请求被重定向到这里:http://somewebsite.domain/preview/index.php?request\u type=preview\u engime,但在这种情况下我需要https。