Jump to content

[SOLVED] RewriteEngine On causing 403 error?


tpl41803

Recommended Posts

Hi all,

 

Someone helped me out with this short .htaccess issue a while back on this form, and it seems that I never actually solved my problem

 

so here it is again:

 

I wanted to write a script that would replace any broken images -- images that are "not found" -- with a default image that says "image not found" -- the site I work on lists used cars for sale and unfortunately the guy who updates the site doesn't always upload pictures when he lists the new cars in the inventory.

 

Thus, I want this default image to display until he gets around to uploadin the actual images

 

I was directed to do this through .htaccess using the rewrite engine -- here's what I'm using currently:

 

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ /image/noimg.jpg

 

it works perfectly, except that when I log back into my file manager, I am presented with a "403 Error, Access Denied"

 

I have tried several different things to amend this--

 

I've removed the "rewriteengine on" line, and the images don't get replaced ,but the 403 error goes away.

 

also in my .htaccess i have custom redirect pages, they're in there below the rewrite rules:

 

Options -Indexes
ErrorDocument 401 /customerrors/error_401.php
ErrorDocument 403 /customerrors/error_403.php
ErrorDocument 400 /customerrors/error_400.php
ErrorDocument 500 /customerrors/error_500.php
ErrorDocument 404 /customerrors/error_404.php 

 

any help would be appreciated, thank you!

Link to comment
Share on other sites

Try the following and let me know if it works for you:

 

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$ 
RewriteRule .* /notfound.jpg [L]

 

It works fine for me.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.