Friendly URL (mod-rewrite) issue

旧时模样 提交于 2019-12-01 09:45:59

问题


Hallo,

I am trying to make "nice" URL, first rule works as expected, it's turning

www.blabla.com/index.php?page=tags&tag=blabla

into

www.blabla.com/tags/blabla

but second rules doesn't works?

 RewriteEngine On
 RewriteRule ^([^/]*)/([^/]*)$ /index.php?page=$1&tag=$2 [L]
 RewriteRule ^([^/]*)/([0-9]*)$ /index.php?page=$1&article=$2 [L]

Than you


回答1:


Since numbers could be considered as anything but a forward slash (/), you should put the article rule before the tag rule:

RewriteEngine On
RewriteRule ^([^/]*)/([0-9]*)$ /index.php?page=$1&article=$2 [L]
RewriteRule ^([^/]*)/([^/]*)$ /index.php?page=$1&tag=$2 [L]


来源:https://stackoverflow.com/questions/6494599/friendly-url-mod-rewrite-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!