This is the file tree:
- /problem/
- /problem/index.php
- index.php
- category.php
- somefile.php
I have this 2 rules in the .htaccess that is sitting in the /
RewriteRule ^somedir$ /somefile.php [L]
RewriteRule ^([a-z-]+)$ /category.php?cat=$1 [QSA,L]
So...
- http://domain.com/somedir = OK
- http://domain.com/ = OK
- http://domain.com/problem/ < automatical开发者_如何学Pythonly adds ?cat=problem to the querystring. I want to avoid that extra ?cat=problem
I need to add a rule that doesn't add the cat=$1 when the /dir/ exists.
Just add a RewriteCond
before your second rule. Basically, don't run that catch all if it starts with product
:
RewriteRule ^somedir$ /somefile.php [L]
RewriteCond %{REQUEST_URI} !^/product [NC]
RewriteRule ^([a-z-]+)$ /category.php?cat=$1 [QSA,L]
To prevent redirecting for a real file or directory, add these two lines before the rule:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
精彩评论