WordPress.org

Forums

Subdomain point to subfolder (xyz.123.com -> 123.com/xyz/) (6 posts)

  1. nsne
    Member
    Posted 2 years ago #

    In a multisite WP install that's configured for subfolders, how do I get a subdomain to point to the subfolder? It seems like WP uses some weird virtual settings, but then again, I'm no expert.

    My top-level domain is http://www.iannelli.us, where I have my professional site.

    I have a personal blog at http://www.iannelli.us/diderot/

    What I want is for diderot.iannelli.us AND diderotsdiary.iannelli.us to redirect to http://www.iannelli.us/diderot/

    Oh, and I still want wildcards to redirect to the main site (e.g., *.iannelli.us will always go to http://www.iannelli.us).

    Thanks in advance for any help.

  2. Pothi
    Member
    Posted 2 years ago #

    Untested, but you can do something like this...

    <IfModule mod_rewrite.c>
    	RewriteEngine On
    	RewriteCond %{HTTP_HOST} subdomain1\.domainname\.com
    	RewriteCond %{HTTP_HOST} subdomain2\.domainname\.com
    	RewriteRule ^(.*)$ http://www.domainname.com/blog/$1 [R=301,L]
    	RewriteCond %{HTTP_HOST} !^www\.domainname\.com
    	RewriteRule ^(.*)$ http://www.domainname.com/$1 [R=301,L]
    </IfModule>
  3. nsne
    Member
    Posted 2 years ago #

    I've tried entering this into my .htaccess file a hundred different ways, but nothing seems to work. It leads me to believe that I'm just not doing something right.

    Here's the code that currently exists in my .htaccess file:

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    --- BEGIN CODE ---
    
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # uploaded files
    RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [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).*) $1 [L]
    RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]
    
    --- END CODE ---

    So where exactly do I cut/copy to apply the new "rewrite" code correctly?

  4. Above the block you pasted :)

    What you posted was WP's standard code. That always belongs at the bottom of your .htaccess file.

  5. nsne
    Member
    Posted 2 years ago #

    Not working, unfortunately. I get a "500 Internal Server Error" whenever I try to access the website(s) in any way.

    Not sure if there are any other settings I have to amend to account for the modified subdomain jiggery pokery in the .htaccess file.

  6. Not in .htaccess, no.

    What I want is for diderot.iannelli.us AND diderotsdiary.iannelli.us to redirect to http://www.iannelli.us/diderot/

    So this:

    RewriteCond %{HTTP_HOST} ^(diderot|diderotsdiary)\.iannelli\.us
    RewriteRule ^(.*) http://iannelli.us/diderot/$1 [L,R=301]

    I use something very much like that for my own sites, works great.

Topic Closed

This topic has been closed to new replies.

About this Topic