Disable mod_rewrite in specific directory

Category: Blog • Posted by Jeff Starr • Updated:

This tutorial explains two ways to disable Apache’s mod_rewrite in a specific directory.

Method Uno

Add the following snippet to the .htaccess file that is located in the directory for which you would like to disable mod_rewrite:

# disable mod_rewrite
RewriteEngine off

That cold disables mod_rewrite for the directory and any subdirectories. Best method if you do not need or want any rewriting in a specific directory.

Method Dos

Alternately, you can add the [END] flag to any RewriteRule:

RewriteRule .* https://htaccessbook.com/ [END]

This tells Apache to stop rewriting for the current request. So any further directives will be ignored. This is useful if you need mod_rewrite for some other purpose and want to prevent further rewriting. Learn more in the Apache Docs.

More Infos

Here is a related article at Perishable Press that explains how to *allow* hotlinking in specific directories.