I'm developing a web project with php, html5 and javascript. Right now I am using php to handle the URL when the user refresh the page in order to capture the subdirectories and recalculate the content of the page (it is needed because I'm using ajax).
Ok, everithing works well on this manner, but to accomplish this I need to redirect every request to my page to index.php that calls another file called controller.php. To do this I'm using the following .htaccess code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/index\.php -f
RewriteRule ^(.*)$ /MySubDirectory/index.php [QSA]
I'm testing it on localhost, so for patterns following:
localhost/MySubDirectory/
localhost/MySubDirectory/something
it works, but when I add a new folder:
localhost/MySubDirectory/something/somethingelse
I get weird errors on the css and javascript imports
Uncaught SyntaxError: Unexpected token < jquery-1.8.2.min.js:1
Uncaught SyntaxError: Unexpected token < jquery-ui-1.9.0.min.js:1
Uncaught SyntaxError: Unexpected token < SpriteAnimation.js:1
Uncaught SyntaxError: Unexpected token < Bile.js:1
Thanks for helping.
The problem was not on mod_rewrite but on the links that reference the resources. They were being taken as a relative path begining on the redirected subdirectory and this makes those resources not to be loaded. I solve it by begining each resource (javascript, css and images) with a slash, making them absolute path and not relative as they were previously.