WordPress.org

Ready to get started?Download WordPress

Forums

Success mapping multiple domains to different folders with htaccess (2 posts)

  1. ferran9
    Member
    Posted 7 years ago #

    Hello everyone, I successfully been able to map two defferent domains to two different subfolders with htaccess, without redirections or subdomains, and in the url will appear only the domain and not the subfolder. The HTTP Status code is 200 which is OK so I think will not affect Bot indexing negatively. I know there are other ways to have multiple blogs but as crazy as it may sound for the time been I want to have a per folder wordpress installation. Nevertheless I would like to get some opinions about security issues with this htaccess file or anything I may have overlooked, and I really hope someone find some good use of it.

    To use it create a .htaccess file with any text editor, under windows create a file named htaccess and renamed it later in the server by adding the '.' character in front of it. Copy the following contents replacing domain_1.com, domain_2.com, folder_1 and folder_2 with what you need, and finally place the file at the root of your server. That's all, I hope I didn't miss a thing.


    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # ---------------------------------------
    # BEGIN Domain to folder mapping

    # pointing domain_1.com to folder_1
    ReWriteCond %{HTTP_HOST} domain_1.com
    ReWriteCond %{REQUEST_URI} !folder_1/
    ReWriteRule ^(.*)$ folder_1/$1 [L]

    # pointing domain_2.com to folder_2
    ReWriteCond %{HTTP_HOST} domain_2.com
    ReWriteCond %{REQUEST_URI} !folder_2/
    ReWriteRule ^(.*)$ folder_2/$1 [L]

    # END Domain to folder mapping
    # ---------------------------------------

    # ---------------------------------------
    # BEGIN WordPress

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    # END WordPress
    # ---------------------------------------

    # ---------------------------------------
    # BEGIN htaccess pretection

    <Files .htaccess>
    order allow,deny
    deny from all
    </Files>

    # END htaccess pretection
    # ---------------------------------------

    </IfModule>

  2. dirktaxel
    Member
    Posted 6 years ago #

    Brilliant !!!! Thanks for posting this. It has been a great help to me. Managed to get everything redirected with no problems.

    Once again a big thanks for posting this.

    Very much appreciated !!!

Topic Closed

This topic has been closed to new replies.

About this Topic