I am setting up a site on a shared hosting plan so I am stuck using Apache and a .htaccess file. I have 2 RewriteRules defined. Both rules work perfectly on a local machine running Apache.

The first rule is to rewrite requests for /css/FILE.css to /www/css/FILE.css The second rewrites everything else to /www/index.php

The first rule regarding CSS/JS files is the one causing 500 errors but I can't figure out why. I have tried every different incarnation of these rules and always get a 500.

RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.(css|js) www/$1.$2 [L]
RewriteRule ^(.*)$ www/index.php [L]
link|improve this question
Do you get an error accessing those resources directly, at the post-rewritten URLs? – Shane Madden Aug 17 '11 at 5:23
Yes but I just attributed it to the fact that it is getting caught in the same RewriteRule. – user897929 Aug 17 '11 at 5:35
I was writing that comment above and thought maybe it is getting caught in an infinite loop? But I have add NS flag and it didn't help either. – user897929 Aug 17 '11 at 5:36
try changing the first rule to catch terminations only (css|js)$ – O G Aug 17 '11 at 5:42
Changed to RewriteRule (css|js)$ www%{REQUEST_URI} [L] and still get 500. Also, if i rewrite to somewhere else other than /www it will work. – user897929 Aug 17 '11 at 5:50
show 1 more comment
feedback

1 Answer

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^www
RewriteRule ^(.*)\.(css|js) www/$1.$2 [L]
RewriteCond %{REQUEST_URI} !^www
RewriteRule ^(.*)$ www/index.php [L]

Try that else you end up with a loop since the Rule would still apply after being rewritten so it would rewrite again and again...

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.