开发者

collisions for rules in htaccess

This is my htaccess file

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php #Line 1
RewriteRule ^([a-zA-Z0-9_-]+)$ product.php?name=$1 #Line 2
RewriteRule ^([a-zA-Z0-9_-]+)/$ product.php?name=$1 #Line 3

Line 1 is to remove php extension for all files Line 2 and 3 are such that if you type website.com/ it will translate into website.com/product.php?name=something

Now, I in开发者_StackOverflow中文版stalled a blog whose url is website.com/blog

This is interfering with the product. So instead of serving website.com/blog it gets translated to website.com/product.php?name=blog which is giving incorrect results. How can this problem be solved.


You may find this question useful: Redirect requests only if the file is not found?

# If requested resource exists as a file or directory, skip next two rules
RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}/$1 -d
RewriteRule (.*) - [S=2]
#
# Requested resource does not exist, do rewrite if it exists in /archive
RewriteCond %{DOCUMENT_ROOT}/archive/$1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}/archive/$1 -d
RewriteRule (.*) /archive/$1 [L]
#
# Else rewrite requests for non-existent resources to /index.php
RewriteRule (.*) /index.php?q=$1 [L]

The following may also be of interest: How do I ignore a directory in mod_rewrite?

Try putting this before any other rules.

RewriteRule ^blog - [L,NC]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜