Sharing .htaccess rules


An .htaccess file may be shared across multiple domains and subdomains by being located in a common parent directory. Locating an .htaccess under /var/www will allow any domain or subdomain located under /var/www to inherit these rules; effectively any domain or subdomain that is not managed by a secondary user within that user’s respective home directory.

For example, assume the following layout:

  • -> /var/www/example/
  • -> /var/www/example/sub
  • -> /var/www/example/blog

In this situation, to have a common .htaccess shared among these 3 hostnames, locate the .htaccess file in /var/www/example.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.