Is it possible to do include rules from another htaccess file in .htaccess ?
.htaccess
RewriteEngine On
RewriteCond ...
RewriteRule ...
Include .htaccess1
.
.
Include .htaccess2
Doing this gives a 500. Include not allowed here
Is there a way to do this ? Because I need this pretty badly.
You can’t include rules, statements, definitions, or directives from other files from an htaccess file. The
Includedirective can’t be used inside an htaccess file. Part of the point of an htaccess file is to act similarly to a<Directory>block but be self contained and unable to access things outside of the directory itself (subdirectories are ok) but more specifically nothing outside of the document root. This way, someone doing malicious things won’t be able to point requests or include files/content from other directories by hacking the htaccess file.In the scope of mod_rewrite specifically, there are options for the
RewriteOptionsthat allow inheriting rewrite rules from the htaccess file from a parent directory, but nothing to arbitrarily include rules from anywhere.