简体   繁体   中英

htaccess: RewriteRule for URL rewriting

I have a link that looks like this

http://www.example.com/artistmusic?address=JKanyomozi

I would like to change this URL to

http://www.example.com/JKanyomozi/music

I've only been able to do this by adding music as a parameter instead of adding it to the new URL as a prefix . In short, i've turned this URL ...

http://www.example.com/artistmusic?address=JKanyomozi&req=music

... using this rule ...

RewriteRule ^([^/]*)/([^/]*)$ /artistmusic?address=$1&req=$2 [L]

... into ...

http://www.example.com/JKanyomozi/music

But the problem with this is that for other pages like the one for the videos, this rule redirects to the same page http://www.example.com/JKanyomozi/music instead of http://www.example.com/JKanyomozi/videos

The videos page's original URL is something like this ...

http://www.example.com/artistvideos?address=JKanyomozi

Which rule can I use to change the URL above to

http://www.example.com/JKanyomozi/videos

This applies for other pages like artistevents , artistphotos and artistbiography

Thank you in advance!

尝试这个 :

RewriteRule ^([^/]*)/([^/]*)$ /artist$2?address=$1 [L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM