m3tsys
m3tsys

Reputation: 3969

what is wrong with this htaccess multi level directory rewrite rule?

I have some problems with my htaccess...

I want to have my url's like this:

http://example.com/artist/
http://example.com/artist/rihanna/
http://example.com/artist/rihanna/biography/
http://example.com/artist/rihanna/video/
http://example.com/artist/rihanna/news/

The problem is all of the url's work except for "http://example.com/artist/"

RewriteRule ^artist/([^_]*)/biography/$ /artist-biography.php?name=$1 [L]
RewriteRule ^artist/([^_]*)/biography?$ /artist/$1/biography/ [R=301,L]

RewriteRule ^artist/([^_]*)/video/$ /artist-video.php?name=$1 [L]
RewriteRule ^artist/([^_]*)/video?$ /artist/$1/video/ [R=301,L]

RewriteRule ^artist/([^_]*)/news/$ /artist-news.php?name=$1 [L]
RewriteRule ^artist/([^_]*)/news?$ /artist/$1/news/ [R=301,L]

RewriteRule ^artist/([^_]*)/$ /artist.php?name=$1 [L]
RewriteRule ^artist/([^_/]+)$ /artist/$1/ [R=301,L]

RewriteRule ^artist/$ /artist-page.php [L]
RewriteRule ^artist?$ /artist/ [R=301,L]

Upvotes: 0

Views: 561

Answers (1)

Ulrich Palha
Ulrich Palha

Reputation: 9509

This line

RewriteRule ^artist/([^_]*)?$ /artist/$1/ [R=301,L]

will match http://example.com/artist/ which is probably not what you wanted. Change it as below

RewriteRule ^artist/([^_/]+)$ /artist/$1/ [R=301,L]

If that does not fix it completely, let me know the result.

Upvotes: 2

Related Questions