views:

145

answers:

1

FTR, this is most definitely a programmer shortcoming. The problem is that I've got a short url rewriterule on that works fine. I can do www.mysite.com/matt and it'll hit my php page that queries for a result. But what I NEED is to do mysite.com/music/matt

When I use the same rule for a subfolder as I did on the root dir, it throws a 500 error, AND tries to redirect my mysite.com/music/index.php both of which are a big problem.

Here's what I have that works fine on root (i.e. mysite.com/matt redirects as expected):

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /music/artist_page.php?n=$1 [L,QSA]

If I try the following, I get an internal 500 error and it appears to eat any existing files.

RewriteRule ^music/(.*)$ /music/artist_page.php?n=$1 [L,QSA]
+1  A: 

Your substitution destination music/artist_page.php is also matched by ^music/(.*)$ and thus you’re getting a recursion. The first condition in your first rule avoids that for that rule as it excludes any request that can be mapped to an existing file.

Gumbo
Aah! that makes sense! I'm still pretty terrible at htaccess... Hmm, so how do I get around that?
Cyprus106
@Cyprus106: Either use the same condition as well or this condition: `RewriteCond $1 != artist_page.php`. This will just exclude the destination you are redirecting to.
Gumbo