The following mod_rewrite rule is causing my website to behave odd I type localhost/signin/.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^signin/?$ access.php [NC,L]
It causes all of the attached files (images, css, php, js) with relative links not to load? However when I type localhost/signin all the attached files with load like nothing is wrong. I think this happens because /signin/ is treated like a directory and all relative links will look into an non-existence directory for all the attached files.
Edit: I figured out a solution but it involves muddying up my markup which is not what I want. Look at my answer below and you’ll see.
However, I want these attached files to be ignored by the rewrite rules.
The problem
The problem you have is (after clarification) not related to the use of rewrite rules. Please edit your question to accurately represent your problem.
Almost certainly because you have references such as:
which means the route used to find the css/js files is dependent on the directory (virtual or real) of the current request.
If the current request is /foo, the request is in the root dir. As such, the following urls would be requested:
If, however the current request is /foo/, the request is in the dir
/foo/. As such, the following urs would be requested:Use absolute urls
The way to avoid this is simply to use absolute urls in your link/script tags:
That way, irrespective of the current url – the exact url in the link and script tag is used.
Base tag – be careful
You can as you note in your own answer use the base tag – but it’s much more obvious to not rely upon it. There are also problems with some browsers e.g. converting “#” into an a request for “/#” which is another reason to ignore the base tag’s existence.