I'm working with PHP and MVC and now I need to redirect my CSS files to the proper view.
What I have
My .htaccess file already has this:
Options -MultiViews
RewriteEngine On
RewriteBase /mvc/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule "^(.+)$" "index.php?url=$1" [QSA]
The controller handles everything so my URL looks like this: localhost/mvc/{controller}/{action}/
My css files are located at localhost/mvc/css/{anyCSS}.css
And in the html code i write this for example: <link rel="stylesheet" href="forIndex.css">
What I tried already
I looked for some RewriteRules on the Internet already, but they didn't really work. This for example:
RewriteRule "^(.*).css$" "css/$1.css" [QSA,L]
RewriteRule "^([a-z]+\.css)$" "css/$1" [L]
RewriteRule "^(.+)\/(.+)\.css$" "css/$2.css" [QSA,L]
I tried those in Regex Testers as well but still couldn't find any way to do so.
Example
For example my url looks like this localhost/mvc/home/index/
home = controller
index = action(function/method)
/* By default it loads the index.php */
The index.php can't reach the css file when i link it like above. I also tried to link it with the subfolder path : href="css/forIndex.css"
.
If you need some more information, just let me know.