Using subdomain’s folder using htaccess

I was using as my blog url for various reasons. Yesterday I added a subdomain ( is added as an addon domain with dns hosted with but the site hosted with a different hosting company. I have done it to host with, which takes the same folder public_html/blog/. was just a redirect to so I could tweak the .htaccess a bit and make it work. (I could have also done this by troubling by hosting company to add few lines to the http.conf, which I avoided as I could handle it).

What is done?

RewriteEngine On
RewriteCond % ^$ [OR]
RewriteCond % ^$
RewriteRule ^(.*)$ [R=301,L]
(rest of the wordpress htaccess for cleaner url)

Some Tweaking for and (without www) both exists, now we will do few htaccess tricks to redirect www to non www subdomain.
RewriteCond % ^
RewriteRule ^(.*)$1 [R=301,L]

It is simple for one who knows and difficult for others :). Enjoy

Leave a Reply

Your email address will not be published. Required fields are marked *