Webbege Blog

To WWW redirect or Not to WWW Redirect

Written by Frank Geraci | 31 Mar

Most people ask whether www.yourdomain.com is better than yourdomain.com. The answer is up to you! It is considered good practice with SEO and your visitors to be consistent with your URL. Consistency is what matters. Most people type www before they enter a domain name- but did you know, www is technically a subdomain of your domain? Redirecting to www or non-www will make your URLs more consistent.

If you want to display your site as www.yourdomain.com, then we will show you how. We can also show you how to force your domain to redirect www to non-www!

The method we will be showing you is meant to be used on an Apache server. To get started, you'll need access to your htaccess file. It's found in your domain's webroot folder, typically named .htaccess. You can edit this file using a text editor via FTP or you can give us a shout!

Let's get started.

First, open the file. You may see a bunch of text or you may not see anything. If you can't find a .htaccess file in your webroot, create it!

We will be using a 301 (permanent redirect) to accomplish this.

This code will force you domain to use www. So, if you were to enter the URL yourdomain.com, you will be redirected to www.yourdomain.com

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

If you want to force your domain to redirect to non-www, here's how you do it.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^domain\.com
RewriteRule (.*) http://domain.com/$1 [R=301,L]

Easy, right? If you find yourself struggling a bit, don't hesitate to call and ask for some extra help.

Remember for the best San Diego SEO and San Diego Web Design, trust Webbege with your work! Get a free website review today!