Welcome Guest, Not a member yet? Register   Sign In
.htaccess not allowing image files to be displayed

I'm having some issues getting my .htaccess to work correctly (I think).

I'm using the following code:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond $1 !^(index\.php|uploads)
RewriteRule ^(.*)$ index.php?$1 [L]

I have files in multiple formats stored in the "uploads" folder... files like .txt and .php display in plain text, while .doc files are downloadable. However, trying to access image files by http (e.g., http://www.mysite.com/uploads/46.jpg) results in a 404 error.

Any ideas on how to correct this?

[eluser]louis w[/eluser]
Add this before the RewriteRule

RewriteCond %{REQUEST_FILENAME} !-f

It says "if this is a request to a file which exists on the server, don't continue"

Great, thanks for the reply.

I actually fixed the problem without using the suggested RewriteCond... turns out the files were being written to the uploads folder as read-protected. I just chmodded everything and now it works perfect.

Thanks for the help.

[eluser]louis w[/eluser]
Ahh yes, it should have worked without it. I missed the 'uploads' exception which you already had.

It would be a good idea to add it anyway. That way when you start to add js, css, or a favicon to your site you won't run into the same problem.

Theme © iAndrew 2016 - Forum software by © MyBB