Home Application Web Application WWW 301 redirect URL by .htaccess (Apache)

While I was optimizing my website, I realized links to our website was splitted with two URLs, www.Cisconet.com and Cisconet.com. It's definitely not good for popularity indexed by Google and even other searching engineers. Then I have decided picking one permanant name and applied 301 redirect URL. I went simple route to set that up using cpanel function, but it doesn't work for me. Other way was using an .htaccess file at hosting server. Due to bad experience with .htaccess file previously, so I didn't want to touch it. But it was fairly straight forward to complete 301 redirect URL. 

Open an .htaccess file and edit with below context.
** This will work ONLY on Linux servers having the Apache Mod-Rewrite module enabled.



www.CiscoNET.com ---> CiscoNET.com

Options +FollowSymLinks
RewriteEngine On
rewritecond %{http_host} ^www.cisconet.com [nc]
rewriterule ^(.*)$ http://cisconet.com/ [r=301,nc]


CiscoNET.com ---> www.CiscoNET.com

Options +FollowSymLinks
RewriteEngine On
rewritecond %{http_host} ^cisconet.com [nc]
rewriterule ^(.*)$ http://www.cisconet.com/ [r=301,nc]


www.CiscoNET.com ---> CiscoNET.com/index.php

Options +FollowSymLinks
RewriteEngine On
rewritecond %{http_host} ^www.cisconet.com [nc]
rewriterule ^(.*)$ http://cisconet.com/$1 [r=301,nc]


** Rare case, you might see some links are broken in 1~2 minutes due to cashe on your application/ CMS. Patient!.


Last Updated (Tuesday, 03 November 2009 20:13)

Smart Link
Content View Hits : 2108824
Highly recommended firewall vendor?
Google Translation
English Arabic Chinese (Simplified) Czech Dutch French German Italian Korean Portuguese Russian Spanish Filipino Vietnamese Thai Turkish
BGP routing issue?
World Route Servers
Who's Online
We have 83 guests online