Using a Blog to Improve Traffic and Search Engine Rankings
Adding a blog to an existing business web site can be a great way to achieve search engine positioning for long tail keywords, and increase quality traffic to your site overall. After all, business web sites can become quite static – but a blog with frequent postings makes it a more attractive proposition to both human readers and search engines.
However, either through necessity or choice, you may want to host that blog on a different server from your main site. This could be for a variety of reasons such as server capacity, security accreditation, outsourcing, technology platforms, resilience, etc.
Blog in One Place, Main Site in Another?
Let’s say, you want your blog to be located in the /blog folder off the main site. This is so that the original main web site benefits in the search engines as your blog grows.
This need not be a problem, providing you can configure the virtual host on your main server and on your blog server.
For the remainder of this article we will assume you are using a WordPress blog, that your main site is hosted on what we’ll refer to as the web server, and that your blog is hosted on what we’ll refer to as the blog server.
Setting Up a Reverse Proxy for Your Blog
There are four steps involved. Let’s assume you have a main web site www.example.com hosted on your web server, and that you will host a blog for that site on a different server (your blog server). Further, you want the blog to appear as if living at www.example.com/blog, on your web server.
Step 1 : Set Up the DNS for Your Blog
On the name server for your domain (in our example, www.example.com), set up your DNS to point the subdomain blog.example.com to the IP address of your blog server.
Step 2 : Set Up a Reverse Proxy
Change the Apache configuration file, httpd.conf on your web server, and set the reverse proxy for your blog by adding the following lines to the section in httpd.conf for the virtual host for your domain.
RewriteRule ^/blog$ blog/ [R]
ProxyRequests Off
ProxyPreserveHost On
<Location /blog/>
ProxyPass http://blog.example.com/blog/
ProxyPassReverse http://blog.example.com/blog/
</Location>
Step 3 : Set Up the Blog Virtual Host
Change the Apache configuration file, httpd.conf on your blog server by adding the following line to the section in httpd.conf for the virtual host for your blog.
ServerAlias www.example.com
Add the following three lines highlighted in bold to the .htaccess file in your blog folder, replacing example.com by your domain. The whole of the .htaccess file is given below for the sake of clarity.
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*)$ http://www.example.com/blog/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /blog/index.php [L]
</IfModule>
The three highlighted lines above redirect anyone trying to access the blog directly at blog.example.com to www.example.com/blog/. This avoids any risk of search engines finding duplicate content. The blog can only be accessed via the reverse proxy at www.example.com/blog/
Step 4 : WordPress Configuration
WordPress thinks it is running at www.example.com/blog and both the Wordpress address and the blog address values (in General Settings) show this value.
There are no references to the subdomain blog.example.com anywhere in the database or the PHP code.
However, there is one minor change recommended to the WordPress configuration, in order for WordPress to capture correctly the IP address of those commenting on your blog.
Add the following lines to the top of your wp-config.php file
if(isset($_SERVER[‘HTTP_X_FORWARDED_FOR’])) {
$list = explode(‘,’,$_SERVER[‘HTTP_X_FORWARDED_FOR’]);
$_SERVER[‘REMOTE_ADDR’] = $list[0];
}
The Power Blog Service
We use this technique at the Power Blog Service where we provide blog hosting in addition WordPress maintenance services and WordPress training to our clients.
Our clients’ blogs are hosted on our blog servers, and by setting up a reverse proxy on their main servers, their blog contributes fully to the search engine ranking of their main business web site.
If you would like to see a working example, then guess what, you are already looking at it – this blog is being accessed through a reverse proxy in the way described above – this page is physically hosted at blog.powerblogservice.com on one of our blog servers at LiquidWeb in Michigan but appears to be hosted at www.powerblogservice.com/blog on our main membership server at Rackspace in Texas.