I have a .htaccess
file that redirects every requests to ./core/index.php
. But for static files which are in ./node_modules/
and ./assets/
folders, I want to enable normal redirect for them.
So,
- if request:
url/whatever/page/
-> redirect to:core/index.php
- if request:
url/assets/image/file.png
-> get:assets/image/file.png
- if request:
url/node_modules/css/file.css
-> get:node_modules/css/file.css
My current code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ core/index.php [L,QSA]
2
Answers
So what you can do, is first check if it goes to assets, then redirect there, then for node_modules. And if now of that, then you redirect to the index if none of the conditions met:
I am not really sure what you mean by "I want to enable normal redirect for them" … What you actually show as examples looks to me as if you do not want any rewriting or redirection to get applied at all for those two base paths. If so, then there are two alternatives for this:
Either use conditions:
Or explicit exceptions: