Forum Moderators: phranque

Message Too Old, No Replies

wordpress default htaccess

         

unclej

2:50 am on Aug 15, 2015 (gmt 0)

10+ Year Member



If main domain's htaccess is:
# BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress


later on, I will be adding some add-on domains in the form of a folder in root.
Do you expect that the code above will interfere in any way with the add-on domains?

lucy24

3:38 am on Aug 15, 2015 (gmt 0)

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



Do you expect that the code above will interfere

No, in fact it's the other way around. mod_rewrite isn't inherited; even if you say RewriteOptions inherit-- which normally you wouldn't do-- it still doesn't work like other mods' inheritance. So RewriteRules in any "addon" domain's htaccess-- assuming you mean domains whose directories are physically inside the original directory-- will not just override RewriteRules from the outer (original) domain, they'll make it as if the earlier rules never happened.

If you do add other domains, it would be a good idea to put a ruleset something like this before all WP rules:

RewriteEngine on

RewriteCond %{HTTP_HOST} addon1|addon2|addon3
RewriteRule .? - [L]

The line "RewriteEngine on" may end up being repeated if you don't want to touch the one inside the WP envelope. This looks silly but does no harm. The purpose of the Cond + Rule is to prevent the server from wasting so much as a single nanosecond evaluating RewriteRules that will be thrown away as soon as you meet the inner htaccess. That's assuming the addons will all have RewriteRules of their own, which surely they will.

unclej

5:30 pm on Aug 15, 2015 (gmt 0)

10+ Year Member



so Lucy,

you are saying the htaccess in the add-on domains will affect the main domain?

ughhh this is so complicated, I should have listened to you and got my main hosting with a dummy domain, I am thinking of asking my hosting company to completely wipe my account and I will just get a .tk domain and use it as my main domain without htaccess

lucy24

9:50 pm on Aug 15, 2015 (gmt 0)

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



#1 requests for the primary (non-addon) domain will not be affected in any way at all, whatsoever, at any time, because these requests will only ever see the first htaccess.

#2 when the request is for an addon domain, RewriteRules in the primary htaccess will be completely ignored (with narrow exceptions that you don't need to think about unless you particularly want to). This applies only to RewriteRules. Other rules, such as Allow/Deny directives, will be inherited through all domains, so long as they're inside the same overall directory, unless you make a rule that says otherwise.

:: memo to self: find out if my host is the only one in the world that uses the "Userspace" structure instead of the "Primary/Addon" structure ::

unclej

5:38 pm on Aug 16, 2015 (gmt 0)

10+ Year Member



Lucy,

in the first reply, you said "it's the other way around" and I took that to mean add-on domains are not affected by main domain's htaccess, but main domain is affected by the add-on domains htaccess.

anyway, assuming the code in my main domain's htaccess is the above and the above only, I don't have to get a free .tk dummy domain as my primary domain and start over? I can just add the add-on domains, no matter if they are WP based or html based, and main domain htaccess will not interfere with addon domains and addon domains htaccess will not interfere with main domain?

lucy24

6:30 pm on Aug 16, 2015 (gmt 0)

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



I took that to mean add-on domains are not affected by main domain's htaccess, but main domain is affected by the add-on domains htaccess

One htaccess can never directly change another htaccess. But, in the specific case of mod_rewrite, the rules in one htaccess can prevent the rules in an earlier htaccess from having effect for requests that pass through both htaccess files.

Is that clear enough?

Sometimes you have to keep reading the same explanation again and again in slightly different words until finally you find one that slots into place and the lightbulb goes off and you understand it. This has happened to me many times. (From the "Oh, now I get it!" side.)