Htaccess disable for specific folder
In the general case you can't simply "disable htaccess for a specific folder" unless you have access to the server config.
However, you can disable mod_rewrite (which is what you are using here) in a specific folder (and subfolders) by placing a .htaccess
in that folder with the following:
# Disable mod_rewrite in this directory and all subdirectories
RewriteEngine Off
This will prevent mod_rewrite directives in the parent config being processed. However, directives from other modules (eg. mod_alias, mod_headers, etc.) will still be processed.
Make an exception for a specific rule
However, you only have a single rule that you don't want to apply to a particular folder. In this case you can create an additional condition (RewriteCond
directive) that excludes this folder.
For example:
RewriteCond %{REQUEST_URI} !^/testfolder($|/) [NC]
RewriteCond %{REQUEST_METHOD} !POST [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L]
The !
prefix negates the expression, so it is successful when it does not match. In other words, the first condition is successful when the requested URL is not /testfolder
or does not start with /testfolder/
.
NB: I removed the NC
flag in the RewriteRule
directive since it's not required here.
However, since you want this rule to apply to all requests except this one subfolder, it would be marginally more efficient (and 1 less directive) to perform this check directly in the RewriteRule
directive. For example:
RewriteCond %{REQUEST_METHOD} !POST [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule !^testfolder($|/) %1 [NC,R,L]
So I would like when make php POST inside /testfolder to disable rules from main .htacces file.
The rule above only applies to non-POST requests anyway (as denoted by !POST
), so you shouldn't need to make an exception in this rule to begin with, so maybe there is another underlying issue?
However, if you are using extensionless URLs throughout your site (hiding the .php
extension) then you shouldn't be submitting forms to the .php
version of the URL. So, again, an exception should not be required here.