Issue with .htaccess

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hey everyone,

I'm having a quite frustrating issue with .htaccess. In order to
redirect all URLs like .com/something/ to .com/index.php/something/
I'm using the following code:

RewriteEngine on
RewriteRule ^$ /index.php [L]
RewriteCond $1 !^(index\.php|img|css|js|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]

However, now I'm experiencing some issues with my CSS. In it, I'm
linking to some images like this: "/gfx/image.png", but the files
can't be found! Neither if I try to access the images at .com/gfx/
image.png, all I get is a "the file cannot be found".

Now the thing is that it works perfectly with the styles if I remove
the .htaccess file and work with .com/index.php/something/, that's why
I suspect that the .htaccess file is the bad guy.

Anyone has any suggestions?

Re: Issue with .htaccess

Quoted text here. Click to load it

Enabling you rewrite log would have told you something like this:

/gfx/image.png matches .* from the second rewriterule
/gfx/image.png does not match  
RewriteCond has ! in front of it, so is satiesfied
URL is rewritten to /index.php/gfx/image.png

So unless you index.php is able to serve the images, the rules are indeed  
You either alter it to something like this:

RewriteCond $1 !^(index\.php|img|css|js|robots\.txt|favicon\.ico|gfx)

Or, something I always like to do:

RewriteCond % !-f
RewriteCond % !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

Saves time in keeping track of every little exception to the rule. It  
simply does a redirect if the url requested does not map directly to a  
file. This would mean that if you have a dir called 'css', you don't want  
to have some page requested like, but as long as you keep  
that in mind, everything works quite fluently.
Rik Wasmus
Posted on Usenet, not any forum you might see this in.
Ask Smart Questions:

Site Timeline