htaccess invisibly rewrite folder

I have multiple-domains with different content on one server in the directory /html/, which serves all domains, like example1.com, example2.com, example3.com, example4.com.

This works fine.

Read More

I now need to have 2 different(!) wordpress-installations. From the outside I would like to have:

example1.com -> No Blog
example2.com/blog/
example3.com -> No Blog
example4.com/blog/

The internal path-structure on the server should look like:

/html/
/blog-for-server2/
/blog-for-server4/

Because otherwise the content-management-system in /html/ gets messed up. In fact this is almost like having independent subdomains for the blogs and pointing them to different pathes on the server (but I don’t want to use subdomains).

Any ideas?

Related posts

1 comment

  1. Assuming you’ve already created the domains in Apache’s httpd-vhosts.conf file you can create the redirects inside that, something like:

    <VirtualHost *:80>
        ServerName example1.com
        DocumentRoot /home/servers/common_root/html
    
        RewriteEngine On
        RewriteRule ^/blog/? /blog-for-server-1
    </VirtualHost>
    
    
    <VirtualHost *:80>
        ServerName example2.com
        DocumentRoot /home/servers/common_root/html
    
        RewriteEngine On
        RewriteRule ^/blog/? /blog-for-server-2
    </VirtualHost>
    

    Otherwise you can do it in a root .htaccess but it’s messy:

    RewriteEngine On
    
    RewriteCond %{SERVER_NAME} =example1.com
    RewriteRule ^blog /blog-for-server-1
    
    RewriteCond %{SERVER_NAME} =example2.com
    RewriteRule ^blog /blog-for-server-2
    

Comments are closed.