WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

# 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 ?

share|improve this question
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 '12 at 14:24
up vote 4 down vote accepted

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.

share|improve this answer
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? – tucson Jul 12 '12 at 19:40
@tucson your DNS has to have a wildcard DNS record, any non-existent subdomains will resolve to the same host. – Milo Jul 12 '12 at 22:44
Thank you. I understand now. – tucson Jul 13 '12 at 7:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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