3

I have a Wordpress multisite installed, and would like to understand how the subdomains actually are managed, ie how does my wordpress multisite knows where to find the files/data when a browser request URL user1.domain.com ?

I checked the DNS A record and see only the wild card.

I checked the .htaccess, and it looks as follows:

RewriteEngine On
RewriteBase /

# Protect the htaccess file
<Files .htaccess>
Order Allow,Deny
Deny from all
</Files>

# Protect wpconfig.php
<Files wp-config.php>
Order Allow,Deny
Deny from all
</Files>

# Disable directory browsing
Options All -Indexes

RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule . index.php [L]

so I think the .htaccess does not manage the subdomain, or does it?

so then, how does my wordpress multisite knows where to find the files/data when a browser request URL user1.domain.com ?

1
  • 1
    I remember having read Ipstenu explaining how this magic works, but cannot seem to find it in WP forums... Neither in her books, which are a great Multisite resource: 101 & 110.
    – brasofilo
    Jul 12, 2012 at 14:24

1 Answer 1

4

During the load process, WP loads wp-settings.php, which calls is_multsite(), which checks for the multisite constant defined in wp-config.php if it is a multisite install. If it is multisite, then ms-settings.php is loaded. Inside ms-settings.php, WordPress parses the requested URI to get the domain, and calls wpmu_current_site() to set all of the current site constants based on that domain.

2
  • Ok, thanks. I am still not clear on the URL displayed: how does Wordpress manage to display a URL as user.domain.com when there is no DNS settings for such subdomain? is that due to the .htaccess settings? or something else? Jul 12, 2012 at 19:40
  • 1
    @tucson your DNS has to have a wildcard DNS record, any non-existent subdomains will resolve to the same host.
    – Milo
    Jul 12, 2012 at 22:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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