Geekpedia Programming Tutorials






How to redirect www requests to non-www URL

On Wednesday, March 19th 2008 at 12:18 AM
By Andrew Pociu (View Profile)
*****   (Rated 5 with 3 votes)
Advertisement

If you would like to redirect all the requests to the www version of an URL to the non-www version - for example http://www.geekpedia.com to http://geekpedia.com - you can do that by placing the following mod_rewrite rule in your .htaccess file:

RewriteCond %{HTTP_HOST} ^www\.geekpedia\.com$ [NC]
RewriteRule ^(.*)$ http://geekpedia.com/$1 [R=301,L]

The redirect code 301 means Moved Permanently so most search engines will pick this up and send visitors directly to the non-www version of your URL.

Digg Digg It!     Del.icio.us Del.icio.us     Reddit Reddit     StumbleUpon StumbleIt     Newsvine Newsvine     Furl Furl     BlinkList BlinkList

Rate Rate this Knowledge Base article
Comment Current Comments
by Lewis Cowles on Monday, March 30th 2009 at 03:35 PM

Great tutorial, Im alwas looking at new tips and tricks I always sent 301's through modifying headers but never seen this way of doing it before


Comment Comment on this Knowledge Base article
Name: Email:
Message:
Knowledge Base Related Knowledge Base Articles
There are no related KB articles.

Comment Related Source Code
There is no related code.

Comment Related Tutorials
There are no related tutorials.

Jobs Apache Job Search
My skills include:

Enter a City:

Select a State:


Advanced Search >>
Latest Tech Bargains

Advertisement

Free Magazine Subscriptions

Today's Pictures

Today's Video

Other Resources

Latest Download

Latest Icons