Search code examples
apache.htaccess

How to disable parent htaccess rules in a specific folder


I have an htaccess in the main folder. I don't want to apply the main htaccess to a specific folder inside the main folder.

--Main Folder
  .htaccess
  some folder
  another folder --> don't want htaccess to apply here
  some files
  ...

How can I do this?


Solution

  • Just create a one liner .htaccess in that specific folder where you don't want rules from main .htaccess to apply with:

    RewriteEngine On
    

    Note that this applies to mod_rewrite directives only. By default mod_rewrite rules defined in server context or parent context will be in effect on all the sub directories. By adding just RewriteEngine On in a subdirectory we turn on mod_rewrite engine but don't define any rules to effectively make that subdirectory and all children of that subdirectory to ignore rules defined in root/parent.