.HTACCESS合并两个规则 [英] .HTACCESS Merging Two Rules

查看:73
本文介绍了.HTACCESS合并两个规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ Ena.php?open=$1 [L,QSA]
RewriteCond %{QUERY_STRING} ^([^=]+)$
RewriteRule ^/?$ Ena.php?open=%1 [L,QSA]

2.

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule "^(\x41|\x4F|\x53|\x4C\x4A|\x4E\x4A|D\xC5\xBD|\xC5\xA0|\xC4\‌​x90|\xC4\x8C|\xC4\x8‌​6|\xC5\xBD|\x00-\xF4‌​8FBFBF|[A-Z])[^/]*$" "/? open=Encyclopedia&letter=$1&term=$0" [NE,L,QSA]

我需要将这两个规则正确地合并在一起.他们一个人工作得很好(当一个被删除,另一个被删除时),但在一起却行不通.

I need these two Rules properly merged together. They work well alone (when one is deleted, and the other one left), but together they won't.

推荐答案

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L,END]

RewriteRule "^(\x41|\x4F|\x53|\x4[CE]\x4A|D\xC5\xBD|\xC5\xA0|\xC4(?:\‌​x90|\x8C|\x8‌​6)?|\xC5\xBD|\x00-\xF4‌​8FBFBF|[A-Z])[^/]*$" "/? open=Encyclopedia&letter=$1&term=$0" [NE,L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ Ena.php?open=$1 [L,QSA]

RewriteCond %{QUERY_STRING} ^([^=]+)$
RewriteRule ^/?$ Ena.php?open=%1 [L,QSA]

如果按上面的顺序放置它们会发生什么?首先,我们检查系统上是否存在请求的内容,并按原样提供它. END指令是httpd-2.4 +的新功能,可将所有其他指令短路.

What happens if you put them in the order above? First, we check if requested content exists on system, and serve it as is. The END directive is new to httpd-2.4+, and short-circuits all other directives.

这篇关于.HTACCESS合并两个规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆