WordPress – CNAME redirect to WordPress blog not working

.htaccessapache-2.2cname-recordWordpress

I have two domains hosting in two different servers: domain1.com & domain2.com

I would like to forward "blog.domain1.com" to "blog2.domain2.com" which is a WordPress blog using CNAME redirect.

Before I installed WordPress.

blog.domain1.com (=redirect=>)
blog2.domain2.com/index.htm
(working fine)

The browser will keep the URL (http://blog.domain1.com) even the index.htm is on domain2.com server.

However, after I installed WordPress, the browser will change the URL to (http://blog2.domain2.com)

This is my current setup:

On domain1.com DNS:

blog.domain1.com CNAME redirect to
domain2.com

on domain2.com .htaccess:

Options +FollowSymLinks 
RewriteEngine On 
RewriteCond  %{HTTP_HOST} ^blog\.domain1\.com 
RewriteRule ^(.*)$ http://blog2.domain2.com/$1 [R=301,L]

on blog2.domain2.com .htaccess:

DirectoryIndex index.php
<IfModule mod_rewrite.c> 
Options +FollowSymLinks
RewriteEngine On 
RewriteBase /blog2/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /blog2/index.php [L]
</IfModule>

blog2.domain2.com is installed under domain2.com/blog2/

All I want to do is keeping the URL (blog.domain1.com) unchanged for the whole WordPress redirect.

Best Answer

I don't think the .htaccess in blog.domain1.com will work. In your configuration, it will not never be hit. The easiest way is just remove your cname setting and keep your .htaccess in blog.domain1.com. You probably need to learn more on how DNS and Apache works.

Related Topic