Friendly URL (mod-rewrite) issue

2019-02-20 05:53发布

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条回答
放我归山
2楼-- · 2019-02-20 06:16

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]
查看更多
登录 后发表回答