Reputation: 2539
I can't seem to get my htaccess to work properly and it keeps going into an infinite loop. (I'm still new to all of this so I'm not sure if I'm even doing it properly.
What I'm trying to do is make it so that whenever the user goes to anything that contains a particular string then it will add /htdocs to the string. (E.g. (with condition css) http://domain.com/css/test.html would link to http://domain.com/htdocs/css/test.html)
Here is my current code:
Options +FollowSymlinks RewriteEngine on RewriteRule /(css|js)/(.*)$ /htdocs/$1/$2
Can't seem to get it to work. Any help would be greatful =)
Upvotes: 0
Views: 873
Reputation: 67695
The problem is that your output URL always matches the rewrite rule, so you get stuck in an infinite loop.
You have to modify the condition on which the rule is executed, or the pattern itself. There are a few ways of doing this. I can think of two right now:
Ensure that the pattern matches the beginning ^
of the URL:
RewriteRule ^/(css|js)/(.*)$ /htdocs/$1/$2
Have the pattern executed only if the target file does not exist:
RewriteCond %{REQUEST_FILENAME} !-f
Upvotes: 0
Reputation: 4316
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^/(css|js)/(.*)$ /htdocs/$1/$2
Upvotes: 1