Reputation: 13
My application folder structure is like
but I can't access the contents in the assets
folder. They always show "404 page not found".
As an example, mysite.com/assets/frontend/page.css
shows the error. At the same time, mysite.com/assets/css/bootstrap.min.css
shows the error.
My .htaccess
file is
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Upvotes: 0
Views: 2968
Reputation: 850
Add this rule to your htaccess rewrite:
RewriteCond $1 !^(index\.php|assets)
The issue is that when you remove index.php from your project, what you are actually doing is rewriting anything at that level to point to index.php...
If index.php wasn't being blocked you would see e.g. http://localhost/index.php/assets/
etc...
You need to adjust the rewrite to ignore your assets folder with !^ (ignore starting with) then assets, so you can access that folder
You can check it working / not working by going to mysite.com/assets/css/bootstrap.min.css
in your browser and it saying it doesn't exist (with your current .htaccess file)
The rewrite you have RewriteRule ^(.*)$ index.php/$1 [L]
is doing this...
^
is the start of string (uri)
(
is the start of regex group
.*
is the everything at first URI level
)
is the end of regex group
$
is the end of string
You are then telling it to effectively look past index.php/ then continue looking at $1
The rule I have given you is adding exceptions to what you already have to ignore certain URI segments
Upvotes: 2