Hi all,
I would like to make .htaccess rewrite requests to /images/. What i want it to do is to check if the file exists as /images/bla bla, and if not, then check ../images/bla bla. I thought i could just do something like:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(images|js)/(.*)$ ../$1/$2 [L]
RewriteRule . index.php [L]
But that doesn’t seems to work. In fact, none of the files work after this. The only thing which works is the actual pages (controllers and other internal things).
Thanks in advance.
Y11
(Y!!)
January 6, 2010, 10:23am
2
You can put another .htaccess into the images folder and make the needed checks from there. I think that should work.
I’ve tried that too, but it never gets invoked.
Y11
(Y!!)
January 6, 2010, 1:34pm
4
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://www.example.com/images/$1 [L,R=301]
Something like this maybe? Untested.
cmx
(Pagemechanix)
January 17, 2010, 1:41am
5
Try this:
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|js|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
cmx
(Pagemechanix)
January 17, 2010, 10:45pm
7
Sry, doesn’t work
Is mod_rewrite.so enabled in your httpd.conf file?
Yes, I’ve already done a lot of rewriting.
webscriptz
(Webscriptz)
February 4, 2010, 10:01am
9
Did you restart your server after having enabled mod_rewrite? It is something i myself forget from time to time.
mikl
(Mike)
February 4, 2010, 1:22pm
10