WPMS Ignore Some Subdomains

跳转至: 导航搜索

Sometimes you want to want to ignore a subdomain while running WordPress Multisite using subdomains. If you use wildcards in your VirtualHost file WPMS will take over all subdomains. You can get around this using .htaccess or VirtualHosts.

.htaccess method

This method is for creating a subdomain from a directory that exists in your domain.com directory. For example if you are serving domain.com out of: /var/www/domain.com the directory for the subdomain is located in /var/www/domain.com/sub

Add the following before the Rewrite of www.domain.com to domain.com.

 RewriteCond %{HTTP_HOST} sub.domain.com
 RewriteCond %{REQUEST_URI} !sub/
 RewriteRule ^(.*)$ sub/$1 [L]

A problem with this method is that you can also access this subdomain by going to domain.com/sub

VirtualHost method

If you are able to configure your VirtualHost file this may be the best method. It provides the ability to serve the subdomain out of any directory on your server.

To do this you simply need to make sure that the domain you do not want WPMS to handle is loaded before the WPMS primary domain that uses the wildcard.

Further Reading

External links