【发布时间】:2021-08-24 04:45:45
【问题描述】:
我必须重写相互冲突的规则。实际上,是第二个规则导致第一个规则不起作用,即使我换了位置。
艺术家音乐.php
From: http://www.example.com/artistmusic?slug=Ben
To: http://www.example.com/Ben/music
artistvideos.php
From: http://www.example.com/artistvideos?slug=Ben
To: http://www.example.com/Ben/videos
上述网址的重写规则。
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)/([^/]*)$ /artist$2?address=$1 [L]
这就像它应该的那样工作,直到我为下面的一组 URls 添加重写规则。
allsongs.php
From: http://www.example.com/allsongs?standard=popular&request=monthly
To: http://www.example.com/songs/popular/monthly
allartists.php
From: http://www.example.com/allartists?standard=popular&request=monthly
To: http://www.example.com/artists/popular/monthly
重写上面第二组的规则。
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /all$1?standard=$2&request=$3
上面的规则有效,但会杀死第一个。 这是什么原因?谢谢。
【问题讨论】:
标签: apache .htaccess mod-rewrite url-rewriting friendly-url