Home Web Design Fun with htaccess

Fun with htaccess PDF Print E-mail
Thursday, 07 January 2010 14:11

Htaccess can be a powerful tool when dealing with a website. Today I had the fun of trying to redirect a secondary domain name to a specific folder, while the main domain name continues to work normally. These are two domain names hosted on the same server, but getting this to work as a 301 redirect wasn't easy. After a lot of experimenting and fiddling, the following now redirects the secondary domain as expected and is a search engine friendly redirect:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.secondarywebsitename\.com
RewriteRule ^(.*)$ http://www.mainwebsitename.com/folder/$1 [L,R=301]
 
TonerDesign.biz, Joomla templates by SG web hosting