碰撞在htaccess的
问题描述:
规则这是我的htaccess文件碰撞在htaccess的
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
1号线是去除PHP扩展的所有文件 2号线和3是这样的,如果你输入website.com/它会转化为网站.COM/product.php?名称=东西
现在,我安装了一个博客其URL是website.com/blog
这与产品的干扰。所以,而不是提供website.com/blog它会被转换为网站/ product.php?name=blog这是不正确的结果。这个问题怎么解决。
答
你会发现这个问题非常有用: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]
下还可能感兴趣的:How do I ignore a directory in mod_rewrite?
尝试之前,任何其他规则把这个。
RewriteRule ^blog - [L,NC]
非常好。有用。在其他所有工作之前的最后一条重写规则。谢谢smdrager。 – Saradhi 2011-04-01 15:56:18