I am using mod_rewrite to create prettier URLs for a website I am working on. However a redirect loop is being caused for my css and js folders.
Here is what is in my .htaccess
AddDefaultCharset On
AddDefaultCharset UTF-8
AddCharset UTF-8 .tpl
AddCharset UTF-8 .js
AddCharset UTF-8 .css
AddCharset UTF-8 .php
RewriteEngine On
RewriteBase /guildtree/
RewriteRule ^([a-zA-Z0-9_'-]+)/(.*)$ characters.php?realm=$1&name=$2 [NC]
My CSS is being redirected to
http://localhost/guildtree/css/error
and my JS is being redirected to
http://localhost/guildtree/js/error
My images are all coming up broken as well, even though the path to them is correct. Going to the images directly results in a redirect loop as well.
http://localhost/guildtree/images/roster/error
Is there anything that stands out as the reason to be causing this loop? Thanks.
Update:
The issue with the CSS and images have been resolved. The JS still doesn’t work though.
This isn’t a redirect loop, your images are probably getting caught by the characters.php route. Add some exclusions to your rule:
Additionally, you may have a relative/absolute pathing issue. If your links are relative, they will be changed by the new path and you need to add a:
Or whatever the base path should be for all your relative links.