.htaccess file for multiple sites

.htaccess file for multiple sites

Posted by: tranzndance
Posted on: 2007-10-11 14:30:00

Is it possible to have an .htaccess file that works for multiple sites in my account? In particular, I don't want to have to maintain multiple files to block bad IPs and user agents.

I'm coming from a host that uses CPanel. Despite its drawbacks when it comes to multiple domains, having a primary domain with a "trickle down" .htaccess file does come in handy.

I searched the forum and wiki and couldn't find an answer. Of course, it could be a matter of not knowing what to search.

Thanks.

Take Thu! Gallery
Thu's Blog

Re: .htaccess file for multiple sites

Posted by: rlparker
Posted on: 2007-10-11 15:20:00

Sure! You can stick an .htaccess file *above* your "web accessible directories (like in /home/yourusername/) and it will affect every directory *below* it in your path (all your domains under that user). [user]

If you want to only affect *some* of them, you may need to reconfigure the dirs your sites are served from, as in:

/home/yourusername/sitegroupA/whatever.yourdomain.tld
/home/yourusername/sitegroupA/whatever.your2nddomain.tld
/home/yourusername/sitegroupB/whatever.anotherdomain.tld
/home/yourusername/sitegroupB/whatever.another2ndomain.tld

... and so one. This you put a single .htaccess in the sitegroupX dir that will apply to all the domains "under" that dir (unless, of course, over-ridden by a subsequent .htaccess in a given dir)

Careful though: If you do this and forget that you have done it, it can be hard to figure out why some of your domains might be misbehaving (most folks don't look *above* the web-base for .htaccess files!) wink

--rlparker

Re: .htaccess file for multiple sites

Posted by: pgp_protector
Posted on: 2007-10-11 15:40:00

Cool advice rlparker, good to know that.


Tags: htaccess filemultiple filescpanelipswikiknowingblog