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.

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.