Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 ?

share|improve this question
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 '12 at 14:24

1 Answer 1

up vote 3 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
1  
@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

 
discard

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.