我想要的是 subcategory/1/date 所以它通过 subcat_id->1 sort->date。我只能在 PHP 中获得第一个。
RewriteRule ^subcategory/([0-9]+) subcategory.php?subcat_id=$1
RewriteRule ^subcategory/([0-9]+)(/([a-zA-Z0-9_-]+)) subcategory.php?subcat_id=$1&sort=$2
知道我的代码哪里出错了吗?
好的,我通过切换规则并将“/”放在外面来解决我的问题。感谢ctrahey,还添加了$。
RewriteRule ^subcategory/([0-9]+)/([a-zA-Z0-9_-]+)$ subcategory.php?subcat_id=$1&sort=$2
RewriteRule ^subcategory/([0-9]+)$ subcategory.php?subcat_id=$1
不过感谢您的帮助!
尝试颠倒顺序,所以如果存在更多参数,它将首先被捕获
RewriteRule ^subcategory/([0-9]+)/([a-zA-Z0-9_-]+)$ subcategory.php?subcat_id=$1&sort=$2
RewriteRule ^subcategory/([0-9]+)$ subcategory.php?subcat_id=$1
该死的,它领先于我!!