Forum Moderators: phranque

Message Too Old, No Replies

main domain htaccess multiple add on domains

         

unclej

10:52 pm on Jun 30, 2015 (gmt 0)

10+ Year Member



Hello,
I have maindomain.com addon1.com addon2.com addon3.com
The problem is maindomain's htaccess is affecting the addon domains. I want the add on domains to have their own htaccess. The addon domains should not be influenced by main domain's htaccess

I was looking at an old post here: webmasterworld.com/apache/3139428.htm
and had some questions about it:

If I implement this method:
RewriteCond %{HTTP_HOST} ^(www\.)?addon_domain\.com
RewriteRule .* - [L]


do I put these 2 lines at the beginning of main domain's htaccess for every add on domain?
Like this:
RewriteCond %{HTTP_HOST} ^(www\.)?addon1\.com
RewriteRule .* - [L]
RewriteCond %{HTTP_HOST} ^(www\.)?addon2\.com
RewriteRule .* - [L]
RewriteCond %{HTTP_HOST} ^(www\.)?addon3\.com
RewriteRule .* - [L]


Or like this
RewriteCond %{HTTP_HOST} ^(www\.)?addon1\.com
RewriteCond %{HTTP_HOST} ^(www\.)?addon2\.com
RewriteCond %{HTTP_HOST} ^(www\.)?addon3\.com
RewriteRule .* - [L]


In the same post, Mr. Jim says you could also forget about the above and put the following code in the "mod_options" folder of each and every add on domain. I dont know what mod_options folder is, how do I access that?

do I just place the following at the beginning of each add on domain's htaccess, and that's it? or is there more to it?

RewriteOptions none
RewriteOptions Inherit

whitespace

11:45 pm on Jun 30, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



Do you have an htaccess file for each addon domain? (I assume each addon domain is in a subdirectory off the main domains document root?)

Are you only dealing with mod_rewrite or are you using other modules as well?

If you have a .htaccess file for the addon domain, in which you have enabled the RewriteEngine, the mod_rewrite directives in the parent directory are not inherited by default.

lucy24

12:10 am on Jul 1, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



do I put these 2 lines at the beginning of main domain's htaccess for every add on domain?

It may be easier to do it the other way around, but yes it has to be on every single rule:
RewriteCond %{HTTP_HOST} !primary

There's no need for (www\.)? because you can just leave off the opening anchor.

If you don't want the primary htaccess to affect the addons, then do NOT say "RewriteOptions inherit". What Apache version are you on? I don't recognize "none". Anyway, a later directive overrides an earlier one. Finally, "inherit" probably won't do what you intended it to do; mod_rewrite is weird.

This is assuming the "addons" are in directories located inside the primary's directory. It is probably too late this time, but if you're stuck with this directory structure, it's easier if you don't use the "primary" for anything. Pay $10 or so for a domain name you don't plan to use, call that one the primary, and then all your "real" domains will be parallel and nothing will conflict with anything. Use the primary htaccess for things like access-control rules (using mod_auththingy) that are shared by all domains, but don't put anything site-specific, and definitely no RewriteRules.

If you find out what mod_options is, let me know because I've never heard of it either, and the docs for 2.2/2.4 don't mention it.