views:

122

answers:

2

I have a .htaccess in my site www folder that has this rewrite rule:

RewriteRule ^(\w+)/?$ /$1.php

It works, if you type in http://sampardee.com/urltest - It finds urltest.php and brings it up.

However, if you type in http://sampardee.com/urltest/ it still brings urltest.php up but the CSS stops working. I have the CSS file specified in a link tag. The same results appear also when http://sampardee.com/urltest.php/ is accessed.

Is there any way I can fix this so that someone could type in http://sampardee.com/urltest/ and have urltest.php come up, but yet still display the linked CSS file?

Please help :) -Sam

+1  A: 

The problem isn't with mod_rewrite, but with the css link (the browser tries to fetch http://[...]/urltest/css/default.css instead of /css/default.css).

Try adding a beginning slash, and changing the to:

/css/default.css

cbeer
+1  A: 

A better idea would probably be to redirect http://sampardee.com/urltest/ to http://sampardee.com/urltest.

RewriteRule ^(\w+)/$ /$1 [R] 
RewriteRule ^(\w+)$ /$1.php
Patrick McElhaney