我想在我的页面上使用mod_rewrite并且已经有了一些规则
现在我想重定向到artist.php?name =(PARAMETER),但它与其他规则匹配
目前我在artist.php之前使用“a /”,因为我不知道如何解决这个问题 所以,如果我想这样看见艺术家“亚历克斯”只需要输入domain.com/Alex,如果我想去关于页面,我只需要输入domain.com/about(就像facebook或twitter)
当然,我很感激每一项改进
这是.htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^cover/([0-9]*)(s|m)?\.jpg$ /cover.php?id=$1&size=$2
RewriteRule ^dl/([^/]*)/([^/]*)$ /download.php?$1=$2
RewriteRule ^track/([^/]*)\.mp3$ /song.php?id=$1
RewriteRule ^my(/)([^/]*)$ /my.php?requested=$2
RewriteRule ^album/(.*)-([0-9]{0,6})$ /album.php?id=$2
RewriteRule ^a/([^/]*)$ /artist.php?name=$1
RewriteRule ^a/([^/]*)/music$ /music.php?name=$1
RewriteRule ^(artists|about|charts|contact|myprofile|editprofile|mymusic|uploadsongs|logout|genres)$ /$1.php
RewriteRule ^t$ /t.php
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain.com(/)?.*$ [NC]
RewriteRule .*\.(mp3)$ - [F,NC]
ErrorDocument 404 /errors/404.php
p.s。:我很抱歉我的英文不好
答案 0 :(得分:0)
您需要重新排列一些规则,并添加L
标记,以免意外应用:
RewriteEngine On
RewriteBase /
RewriteRule ^cover/([0-9]*)(s|m)?\.jpg$ /cover.php?id=$1&size=$2 [L]
RewriteRule ^dl/([^/]*)/([^/]*)$ /download.php?$1=$2 [L]
RewriteRule ^track/([^/]*)\.mp3$ /song.php?id=$1 [L]
RewriteRule ^my(/)([^/]*)$ /my.php?requested=$2 [L]
RewriteRule ^album/(.*)-([0-9]{0,6})$ /album.php?id=$2 [L]
RewriteRule ^a/([^/]*)$ /artist.php?name=$1 [L]
RewriteRule ^a/([^/]*)/music$ /music.php?name=$1 [L]
RewriteRule ^(artists|about|charts|contact|myprofile|editprofile|mymusic|uploadsongs|logout|genres|t)$ /$1.php [L]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain.com(/)?.*$ [NC]
RewriteRule .*\.(mp3)$ - [F,NC]
# assume anything else is a username
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ /artist.php?name=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/music$ /music.php?name=$1 [L]
ErrorDocument 404 /errors/404.php