2

how can I create non-Wordpress sites on subdomains (map them to directories), when I have an active subdomain-multisite WP installation?

Can I insert some .. exemptions into htaccess or something?

2

The WP Codex gives two examples of excluding a subdirectory from multisite's control.

  1. .htaccess method (as Karthik noted)
  2. Virtual host method

.htaccess

Being sure to call the sub rewrite BEFORE the rewrite of ww.domain.com to domain.com

RewriteEngine On
RewriteBase /

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

# Rewrite http://www.domain.com to domain.com
RewriteCond %{HTTP_HOST} ^www.(.*)
RewriteRule ^(.*)       http://%1/$1 [R,L]

This answer to issues with this covers the hierarchical nature of .htaccess to keep in mind: https://wordpress.stackexchange.com/a/20274/118366

Virtual Host

Quoting the linked Codex page on this:

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.

0

Yes. We can add rewrite rule in WordPress root .htaccess to rewrite all requests for a particular subdomain into a subdirectory. I could make it work with something like this:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^sub\.domain\.com$
    RewriteRule (.*) sub/directory/index.php [L]
</IfModule>

# BEGIN WordPress
    # wordpress generated rewrite rules.
# END WordPress

PS:

  1. In above code sub domain and sub directory should be set according to your setup.
  2. Mentioned Rewrite rule should be set before WordPress rules, so that apache looks at these rules before touching WordPress.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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