How to prevent WordPress setup in 'blog' subdomain, redirecting to 'www' when trying to finish Installation

admin

Administrator
Staff member
I have a main site <a href="http://www.example.com" rel="nofollow">http://www.example.com</a> that's written in another language (Ruby/Rails). I want a wordpress blog installed in <a href="http://blog.example.com" rel="nofollow">http://blog.example.com</a>. I have control over the server and DNS.

I have created the necessary CNAME record for the 'blog' subdomain. But after setting up apache and restarting it, when I visit <a href="http://blog.example.com" rel="nofollow">http://blog.example.com</a>, for the final installation steps, I'm redirected to <a href="http://www.example.com/wp-admin/install.php" rel="nofollow">http://www.example.com/wp-admin/install.php</a>.

Also now when I try to visit the main site <a href="http://www.example.com" rel="nofollow">http://www.example.com</a>, I'm being redirected to the above wordpress install page.

How can I make it work like this: the blog should only reside in blog.example.com path, and the main site should be accessible via <a href="http://www.example.com" rel="nofollow">http://www.example.com</a>.

Removing the www subdomain is not an option as it's been like that for awhile for the main site. It might be ok, if somehow a redirect can be setup from www to non-www url, though I'm not aware how to set it up.

Please suggest.

Here's the main site's apache conf:

Code:
     &lt;VirtualHost *:80&gt;
ProxyPreserveHost On
ServerAdmin [email protected]
ServerName http://www.example.com
ServerAlias example.com

DocumentRoot /home/apps/example/current/public
&lt;Directory /home/apps/example/current/public&gt;
AllowOverride all
Options -MultiViews
&lt;/Directory&gt;
#RewriteEngine On
#Redirect / http://example.com/
&lt;/VirtualHost&gt;

Here's the apache conf for the wordpress under 'blog' subdomain:

Code:
     &lt;VirtualHost *:80&gt;
ServerName blog.example.com
ServerAlias blog.example.com

ServerAdmin [email protected]
DocumentRoot /home/apps/example_blog/wordpress_blog
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

&lt;Directory /home/apps/example_blog/wordpress_blog&gt;
AllowOverride All
&lt;/Directory&gt;

&lt;/VirtualHost&gt;