Apache,HTAccess,重写规则

时间:2010-09-14 17:56:23

标签: apache .htaccess

希望你没事。

如果你能帮助我,我有一个问题。

#我的规则(按此顺序):#

(WORKING:)

RewriteRule ^artists\/(.*[^discographies])\,([0-9]*)\/$ /artists/artist.php?id=$2 [L]

网址: / artists / B / barrington-levy,869 /


(工作:)

RewriteRule ^artists\/(.*[^discographies])\,([0-9]*)\/discography\/$ /artists/discography.php?id=$2 [L,QSA]

网址: / artists / B / barrington-levy,869 / discography /


(WORKING:)

RewriteRule ^artists\/(.*[^discographies])\/$ /artists/alpha.php?id=$1 [L]

网址: / artists / B /


现在我需要制定一些新规则,我很糟糕!


第一个: /艺术家/唱片分类目录/ 1979 /巴灵顿-征少林寺,85 /

(不工作:)

RewriteRule ^artists\/discographies\/([0-9]*)\/(.*)\,[(0-9)*]\/$ /artists/disc.php?id=$4 [L]

第二个: /艺术家/唱片分类目录/ 2009-10 /各种-艺术家,扎哈-沙卡-呈现最积极的消息,2563 /

(不工作:)

RewriteRule ^artists\/discographies\/([0-9]*)\-([0-9]*)\/(.*)\,[(0-9)*]\/$ /artists/disc.php?id=$4 [L]

1 个答案:

答案 0 :(得分:1)

而不是[(0-9)*]尝试([0-9]*)

因此对于整个规则替换:

RewriteRule ^artists\/discographies\/([0-9]*)\/(.*)\,[(0-9)*]\/$ /artists/disc.php?id=$4 [L]
RewriteRule ^artists\/discographies\/([0-9]*)\-([0-9]*)\/(.*)\,[(0-9)*]\/$ /artists/disc.php?id=$4 [L]

使用:

RewriteRule ^artists\/discographies\/([0-9]*)\/(.*)\,([0-9]*)\/$ /artists/disc.php?id=$3 [L]
RewriteRule ^artists\/discographies\/([0-9]*)\-([0-9]*)\/(.*)\,([0-9]*)\/$ /artists/disc.php?id=$3 [L]