MrFoh
MrFoh

Reputation: 2701

Wrong 404 error

I have a folder on my web root where user avatars are save, but whenever a request is made to the folder to load an image,the default error 404 page is displayed, am using codeigniter. And my .htaccess file looks like this

RewriteEngine On
RewriteCond $1 !^(index\.php|(.*)\.user_guide|assets|profiles|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

And still i get the 404 error. Please help me out

Upvotes: 1

Views: 115

Answers (1)

Gerben
Gerben

Reputation: 16825

What I use for this is mod_rewrite. Just put the following htaccess file in the image folder in this case '/assets/avatars'. Can be any folder; just change the value for RewriteBase accordingly.

RewriteEngine on
RewriteBase /assert/avatars

RewriteCond %{REQUEST_fileNAME} !-f
RewriteRule ^(.*)\.jpg$ noimage.jpg [L]

This script will show the noimage.jpg if the requested image file doesn't exist. If you use .png, just replace .jpg with .png

Upvotes: 1

Related Questions