oriceon
oriceon

Reputation: 379

.htaccess exclude a directory to be rewrited

where I'm wrong in this htaccess, because /assets/ folder isn't excluded from rewrite rule. When I access: http://www.site.com/assets/images/sidebar1/some/pic.pngs isn't return 404 as I expected.

Options -Indexes
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} !^/?(assets|css)/
RewriteRule . index.php

Thanks

Upvotes: 0

Views: 1517

Answers (1)

M'vy
M'vy

Reputation: 5774

Your rule says :

rewrite everything to index.php when :

The URL is not a file and is not a directory and is not in /assets/ or /css/.

The file you're asking is not a file, not a directory and is in assets/:

So ok for the rule, BUT! your log show you are then asking for /home/valentin/public_html/404.shtml (automatic redirection for the unknown object!)

And this request goes through the rules again!

It is not a file (!-f matched), not a directory (!-d matched) and it is not in assets/ nor in css/ then it gets rewritten to index.php

Q.E.D.

You can correct this by putting the 404.shtml in your public_html/ folder, or change this in apache configuration to a real file.

Upvotes: 1

Related Questions