If i use:
RewriteEngine On
RewriteRule ^.* controller.php
It would send all requests to controller.php
But if controller.php included a css file (/assets/css/main.css) then it wouldn’t work, as when the browser called it, it would just redirect to controller.php
Is there a way i can fix this?
You could add a condition to exclude URLs that can be mapped to actually existing files:
The
-fkeyword will test if the absolute path in%{REQUEST_FILENAME}is a path to an existing regular file in the filesystem and!-fis just the inverse.But if you have a fixed list of directories you want to exclude, you could also do this:
This condition tests if the match of the whole
RewriteRulepattern (referenced with$0) does not begin with neitherassets/norfoo/norbar/. If you don’t want to process the match you could also use a negated expression directly in yourRewriteRuledirective: