The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
Article Feedback - Rewriting URLs within Apache
 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Newer Topic  |  Older Topic 
 index.htm's now throw 403
Author: Sally 
Date:   15-04-03 10:27

I've tried implementing a variety of solutions to rewrite .htm requests to .php files and serve the original .htm if a .php file isn't there.

I got the suggestion from this site to work fine in an .htaccess file (although could not get it to work in my Virtual Hosts config):

RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.htm$ $1 [C,E=WasHTM:yes]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [S=1,R=permanent]
RewriteCond %{ENV:WasHTM} ^yes$
RewriteRule ^(.*)$ $1.htm

the problem is, that if someone reuqests an index.htm file somewhere on the site where there is neither an index.htm or an index.php, the server shows a 403 Forbidden error rather then a 404 File not Found. This is definitely caused by this rewrite as without it I get 404s. How can I stop this from happening??


Reply To This Message
 Re: index.htm's now throw 403
Author: Dan Langille 
Date:   16-04-03 02:47

You should be asking for help, not commenting. Try the Support forum. Click on Forums near the top left of this page.

Reply To This Message
 Forum List  |  Threaded View   Newer Topic  |  Older Topic 

 Forum List  |  Need a Login? Register Here 
 User Login
 User Name:
 Remember my login:
 Forgot Your Password?
Enter your email address or user name below and a new password will be sent to the email address associated with your profile.
How to get the most out of the forum