我有两个重写规则,它们的开头部分相同。
这是我的重写规则:
RewriteRule ^category/(.+?)(/)?$ ./handle.php?q=category&cat_name=$1 [L]
RewriteRule ^(.+?)(/)?$ ./handle.php?q=post_title&title=$1 [L]
我想重写所有一开始就有类别的url,比如:
/category/part2
至./handle.php?q=category&cat_name=part2
所有url都期望第一条规则,比如:
/posttitle
至./handle.php?q=post_title&title=posttitle
当我评论出第二条规则时,第一条规则运行良好。但是,当所有两个规则都处于活动状态时,第二个规则不起作用。
我该如何解决这个问题?
请在此处尝试此规则。
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^category/([^/]+)/?$ /handle.php?q=category&cat_name=$1 [L]
RewriteRule ^([^/]+)/?$ /handle.php?q=post_title&title=$1 [L]