Support » Networking WordPress » Map a WP Multisite Subdomain To A Domains’s Subdirectory

  • The Big K

    (@crazyengineers)


    I’m wondering if the following is possible: –

    1. WP Multisite: xyz.domain.com
    2. Maps to anotherdomain.com/blog

    So that if the user visits anotherdomain.com/blog, they are served a WP multisite from xyz.domain.com. Basically, I’m looking for white-labeling for subdirectory.

    I’m aware that xyz.domain.com can be mapped to any subdomain on another domain; but wish to know if this works for subdirectory mapping as well.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    You could place a .htaccess redirect or rewrite rule in anotherdomain.com/blog or anotherdomain.com’s public_html that sends /blog/ requests to xyz.domain.com. The user’s address bar will be changed to xyz.domain.com. anotherdomain.com/blog will not remain there as an alias because this is a cross domain redirect. There are security implications in having it remain as an alias.

    I suppose anotherdomain.com/blog could be set up as a proxy service so the address doesn’t change. Proxies are outside of my knowledge base, so I don’t know how this might be accomplished.

    Yes, it is possible to map a WordPress multisite installation to a subdirectory on another domain. Here is one way to do it:

    Set up the WordPress multisite network on xyz.domain.com.
    Create a new site in the network for the subdirectory you want to map to (e.g. “blog”).
    Install and activate the plugin “WP Super Cache” on the network.
    In the WordPress dashboard, go to Settings > WP Super Cache and enable caching.
    In the WordPress dashboard for the site you want to map to the subdirectory, go to Settings > Reading and set the “Site address (URL)” to the desired subdirectory URL (e.g. “anotherdomain.com/blog”).
    In the root directory of the site xyz.domain.com, create a new .htaccess file and add the following code:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) xyz.domain.com/$2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ xyz.domain.com/$2 [L]
    RewriteRule . index.php [L]

    In the root directory of anotherdomain.com, create a new .htaccess file and add the following code:

    RewriteEngine On
    RewriteBase /blog/
    RewriteRule ^index\.php$ - [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^(wp-(content|admin|includes).*) xyz.domain.com/$1 [L]
    RewriteRule ^(.*\.php)$ xyz.domain.com/$1 [L]
    RewriteRule . index.php [L]

    This should allow users to access the WordPress multisite installation at xyz.domain.com from the subdirectory “anotherdomain.com/blog”.

    Note: This is just one way to achieve the desired result. There may be other methods as well. This method worked for my website vanityroofing.ca.

    • This reply was modified 1 year, 2 months ago by bcworkz. Reason: defanged superfluous link

    @johnmccoey is it possible to redirect user in this:

    link.mysite.com/blog/ to link.mysite.com/blog.php using htaccess file

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Map a WP Multisite Subdomain To A Domains’s Subdirectory’ is closed to new replies.