.htaccess重写规则与其他文件冲突

时间:2015-10-07 18:07:16

标签: php apache .htaccess mod-rewrite

我已经创建了一个.htaccess文件,但是出现问题的是与其他文件冲突

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^f9/([^/\.]+)?$ footer_arts.php?page=$1 [QSA,L]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^f10/([^/\.]+)?$     footer_bus.php?page=$1 [QSA,L]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^f11/([^/\.]+)?$     footer_cely.php?page=$1 [QSA,L]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^f12/([^/\.]+)?$     footer_com.php?page=$1 [QSA,L]

RewriteRule ^f13/([0-9]+)$     footer_edu.php?page=$1

当我打开www.example.com/f9/1时它完全打开,但是当我打开www.example.com/f10/1或www.example.com/f11/1时,它显示了我的另一页htaccess文件就像f13 / 1一样,我怎样才能防止这个冲突并打开正确的页面

1 个答案:

答案 0 :(得分:2)

以这种方式试用你的代码。

RewriteEngine On
#if the request is a real file or directory, do nothing otherwise process one of the rules below.
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^f9/([^/]+)/?$ footer_arts.php?page=$1 [QSA,L]
RewriteRule ^f10/([^/]+)/?$ footer_bus.php?page=$1 [QSA,L]
RewriteRule ^f11/([^/]+)/?$ footer_cely.php?page=$1 [QSA,L]
RewriteRule ^f12/([^/]+)/?$ footer_com.php?page=$1 [QSA,L]
RewriteRule ^f13/([0-9]+)/?$ footer_edu.php?page=$1 [QSA,L]