问题
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\x86|\xC5\xBD|\x00-\xF48FBFBF|[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.
回答1:
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|\x86)?|\xC5\xBD|\x00-\xF48FBFBF|[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]
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.
来源:https://stackoverflow.com/questions/48015928/htaccess-merging-two-rules