多个RewriteRule错误

时间:2014-03-27 09:58:51

标签: apache .htaccess rewrite

我从未使用过.httacces,而且我陷入了RewriteRule问题 我想在目录中建立分页,但我没有看到代码错误或我做错了什么:

RewriteRule ^([a-z+A-Z0-9_-]+)$ categ.php?categ=$1
RewriteRule ^(.*)/(.*)$ subcateg.php?subcateg=$2&categ=$1
RewriteRule ^(.*)/(.*)/(.*)$ list.php?id=$3
RewriteRule ^(.*)/(.*)/page=(.*)$ subcateg.php?subcateg=$2&categ=$1&page=3

我添加了最后一行并且它无效。 THX。

1 个答案:

答案 0 :(得分:0)

更改规则的顺序:

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

RewriteRule ^([\w-]+)$ categ.php?categ=$1 [L]
RewriteRule ^(.*)/(.*)/page=(.*)$ subcateg.php?subcateg=$2&categ=$1&page=3 [L]
RewriteRule ^(.*)/([^/]+)$ subcateg.php?subcateg=$2&categ=$1 [L]
RewriteRule ^(.*)/(.*)/(.*)$ list.php?id=$3 [L]