Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it possible to include a .htaccess in another .htaccess file. The purpose would be to have a single location of all .htaccess.

Thanks Jean

share|improve this question

2 Answers 2

It seems it's not possible.

But you could use any htaccess rules in httpd conf VirtualHost or Directory conext, where includes are possible.

E.g.:

<Directory /var/www/site1/>
   <...>
   Include /etc/apache/conf.d/site1-htaccess.inc
</Directory>

See also: http://httpd.apache.org/docs/2.0/mod/core.html#include

share|improve this answer
    
But would not that require an apache restart –  Jean Mar 24 '11 at 19:40
    
No, it would require reload (graceful restart - no connections aborted). If you need grant reload rights to non-privileged users, you could use sudo. –  rvs Mar 25 '11 at 9:17
    
Which is exactly I dont want to do. If I do require, I have to restart apache via a php page. –  Jean Mar 25 '11 at 16:04

If I understand correctly, Apache will check for an .htaccess file in every directory above the current one where AllowOverride is set to something other than None.

This means if your DocumentRoot for a site is /var/www/hello/, and it's serving a request for /path/name/filename, it will check for:
/.htaccess
/var/.htaccess
/var/www/.htaccess
/var/www/hello/.htaccess
/var/www/hello/path/.htaccess
/var/www/hello/path/name/.htaccess

So if you like, you can use a single .htaccess file in your server's DocumentRoot, or even above that to affect multiple sites, as long as AllowOverride allows it for that directory.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.