我尝试使用网址重写做三件事:
这就是我目前在.htaccess文件中的内容:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^\.]+)$ $1.php [L,QSA]
RewriteRule ^resources/([a-zA-Z0-9-/]+)$ /resources/post.php?s=$1 [L]
RewriteRule ^resources/category/([a-zA-Z0-9-/]+)/page/([0-9]+)/{0,1}$ /resources/archive.php?cat=$1&page=$2 [L]
RewriteRule ^resources/category/([a-zA-Z0-9-/]+)$ /resources/archive.php?cat=$1 [L]
它做了前两件事。但不是第三个。
如果我删除
RewriteRule ^([^\.]+)$ $1.php [L,QSA]
然后它完成了第三件事,但不是前两件事。
任何想法会发生什么?如何让它一次完成所有这三件事?
答案 0 :(得分:0)
找到解决方案。
只需交换订单,我现在有了这个:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^\.]+)$ $1.php [L,QSA]
RewriteRule ^resources/category/([a-zA-Z0-9-/]+)/page/([0-9]+)/{0,1}$ /resources/archive.php?cat=$1&page=$2 [L]
RewriteRule ^resources/category/([a-zA-Z0-9-/]+)$ /resources/archive.php?cat=$1 [L]
RewriteRule ^resources/([a-zA-Z0-9-/]+)$ /resources/post.php?s=$1 [L]
工作正常。