Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite problem with static dirs. and trailing slash

mod_rewrite problem with static dirs. and trailing slash

         

Jonny_Bogez

1:10 pm on Mar 6, 2007 (gmt 0)

10+ Year Member



Hey I have this rule and for some strange reason it doesnt want to work with a trailing slash and 404's.

RewriteRule ^sites/(.+)/static/$ /static.php?id=$1

so theres only one variable here, inbetween sites and static.

If I use RewriteRule ^sites/(.+)/static$ /static.php?id=$1
and load /sites/25/static it loads correctly. As soon as I add the trailing slash it 404s.

I've also tried several other rules all resulting in the same thing.

RewriteRule ^sites/([^/]+)/static/?$ /static.php?id=$1
"GET /sites/55/static/ HTTP/1.1" 404 28
"GET /sites/55/static HTTP/1.1" 200 1782

I'm running Apache/2.0.52 (Red Hat)

Odd thing is if I do this,

RewriteRule ^sites/([^/]+)/static/asdf.htm$ /static.php?id=$1

/sites/55/static/asdf.htm works. Unfortunately I dont want a filename here, trying to avoid duplicate urls at all costs. Can't understand why that rule would work, but without the asdf.htm wont work.

Any suggestions would be greatly appreciated.

jdMorgan

2:34 pm on Mar 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I can't understand why it won't work either -- Look for other RewriteRules, Redirect and Alias directives, or anything else that may be taking precedence over your rule. There are a few other interaction mechanisms that may cause trouble, but check those first.

BTW, your second version-- RewriteRule ^sites/([^/]+)/static/?$ /static.php?id=$1 --will be much more efficient than the version with the non-specific ".+" pattern. But of course, that doesn't matter until it works!

Jim