0

Hi Everyone.
I have the follwing htaccess file working just great.
Basically it rewrites .php to .html and also rewrites none www. urls to www.

My question is how can is remove a directory from the .php to .html rewrite rule?

My pages are correctly being rewritten to .html files, but now my contact.php form has stopped working
Is it possible to remove or deny the .htaccess file for certain directories within my website.

Here is my htaccess file.
My contact form is located at mywebsite.com/contact/index.php

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mywebsite\.com [NC]
RewriteRule ^(.*)$ http://www.mywebsite.com/$1 [L,R=301]

#Rewrite .php to .html 
RewriteEngine on  
RewriteBase /

RewriteCond %{THE_REQUEST} (.*)\.php  
RewriteRule ^(.*)\.php $1.html [R=301,L]  

RewriteCond %{THE_REQUEST} (.*)\.html  
RewriteRule ^(.*)\.html $1.php [L]

Thanks in advance.

2
Contributors
2
Replies
16
Views
3 Years
Discussion Span
Last Post by everton.retweets
0

You can try this placed somewhere above the rules you want excluded from certain directories:

RewriteRule ^(dir1|dir2)($|/) - [L]

You should replace "dir1" with "contact" and "dir2" with any other
directory you want excluded. You can also add more than two dirs
each separated with a "|" character.

Regards,
Shawn

0

Hi Flashhtml5 - Thanks for replying but that never worked.

The problem im having is the php validation code for my contact form is not triggering the validation error messages.

This is the reason I wanted to remove the "conact" directory from the initial rewrite rule.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.