Link Details

Link 60557 thumbnail
User 196882 avatar

By dubness
via davidwalsh.name
Published: Jan 08 2008 / 23:32

There are some clear benefits to removing the "www" from your URLs: 1) Shorter URLs. 2) Prevention of Google search engine penalties for duplicate content. 3) Less bandwidth usage if you have many links per page. Luckily, removing the WWW from your page URLs (and subsequent Google listings) can be done inside your .htaccess file so that you wont have to go into every page on your website and remove the "www" from your anchors.
  • 19
  • 0
  • 3688
  • 0

Comments

Add your comment
User 219110 avatar

jp0p replied ago:

-1 votes Vote down Vote up Reply

I've been doing the opposite for some time now - forcing the www using htacess.

User 196882 avatar

Eric Wendelin replied ago:

0 votes Vote down Vote up Reply

Lucky for you this article answers that question too!

User 239201 avatar

amphi replied ago:

0 votes Vote down Vote up Reply

Ye, it's a good thing to do. Both should work and one should redirect. It doesn't really matter which one you pick. I went with the non-www one, because that "www." bit is imo amazingly pointless.

User 258821 avatar

leafnode replied ago:

0 votes Vote down Vote up Reply

Using RewriteEngine to do this is like using a cannon to shoot a fly. Much "lighter" solution is to make a dummy virtual host and redirect every request using RedirectMatch, like:
<VirtualHost *>
ServerName www.example.com
RedirectMatch 301 (.*)$ http://example.com$1
</VirtualHost>

Or, even lighter, you may use simple redirect to main page (no regexps), but it'd be confusing.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Java Performance Optimization
Written by: Pierre-Hugues Charbonneau
Featured Refcardz: Top Refcardz:
  1. Design Patterns
  2. OO JS
  3. Cont. Delivery
  4. Java EE7
  5. HTML5 Mobile
  1. Node.js
  2. Debugging JavaScript
  3. OO JS
  4. JSON
  5. Ajax