Answer the question
In order to leave comments, you need to log in
What is wrong with my rules for mod_rewrite?
For some reason, these rules do not work correctly on hosting
RewriteEngine On
RewriteBase /
# Exclude /assets and /manager directories and images from rewrite rules
RewriteRule ^(manager|assets)/*$ - [L]
RewriteRule \.(js|ico|gif|jpg|png|css|xml|phps|mp3|ogg|avi|mpg|acc|swf|jpeg)$ - [L]
# For Friendly URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/assets/cacheimg
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Answer the question
In order to leave comments, you need to log in
Apparently .htaccess is not in document_root? Write the full path in the line with RewriteCond %{REQUEST_URI} !^/assets/cacheimg
add to /assets/cacheimg/.htaccess
RewriteEngine Off
this can be if VirtualDocumentRoot is used or there are other mod_rewrite rules
Doesn't work, because RewriteCond only works with the rule following it, to combine several RewriteConds, you need to put [OR] at the end of the line. And specify what to do according to this directive.
I guess this will work:
# For Friendly URLs
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond %{REQUEST_URI} !^/assets/cacheimg
RewriteRule .* - [R =404]
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question