Results 1 to 6 of 6
Thread: 301 Redirect NON WWW to WWW
-
08-15-2011, 02:18 PM #1Temporarily Suspended
- Join Date
- Jul 2011
- Posts
- 10
301 Redirect NON WWW to WWW
Some of you might wish to discover a really good SEO technique that is so simple to do. And yet helps your page rank on search engines such as google.
By default, you see, your site resides on both http://yourdomain.com and http://www.yourdomain.com
This means that search engines are going to take twice as long to index you as they are indexing content from both the WWW domain and the NON WWW domain. This will affect your page rank and will slow down the length of time it takes for you to get a PR quite considerably.
Also when people link to your page. Some might link to the NON WWW domain and others to the WWW domain. Basically this would cause your page rank to be different for each as some might link more on one than the other. In other words you're creating double the work for yourself and the search engine bots. The quick way to fix this is to permanently redirect one to the other. See below.
So, how to fix this? Well, I'm going to show you how you can create a 301 redirect from http://yourdomain.com to http://www.yourdomain.com (NON WWW to WWW). You can do this the other way round, and redirect from the WWW to the NON WWW if you wish.
The technical term for this type of redirect is "Canonical Redirect".
All you need to do is create a .htaccess file and place it in the PUBLIC_HTML folder (make sure you call it "."htaccess, with the period...think of it as a .htaccess extension. Whatever you do, don't upload it as htaccess.txt!). You will also need to make sure that mod_rewrite is enabled on your server (you can ask your hosting provider about this if you're not sure).
Once you've done that simply add the following code to the .htaccess file. This code will tell your site to redirect any visitors who visit your site without inputting the WWW to your WWW domain. Anyway, I don't want to confuse you any more. So here's the code...make sure you change yourdomain.com to your domain.
Code:Options +FollowSymlinks RewriteEngine on rewritecond %{http_host} ^yourdomain.com [nc] rewriterule ^(.*)$ http://www.yourdomain.com/$1 [r=301,nc]
-
08-15-2011, 02:29 PM #2Web Hosting Master
- Join Date
- Nov 2010
- Posts
- 620
-
08-15-2011, 02:36 PM #3Temporarily Suspended
- Join Date
- Jul 2011
- Posts
- 10
Nice tip.
This rule certainly applies to cPanel servers.
Coz until I did this .htaccess redirect my site was being indexed on both.
Which made everything a bit messy in terms of SEO.
This trick has worked for me.
So if you have cPanel, it's worth a try.
-
08-16-2011, 09:16 AM #4Junior Guru Wannabe
- Join Date
- Apr 2011
- Location
- United Kingdom
- Posts
- 38
That is certainly correct, but for the most of users running something like cPanel or Direct Admin - this would work out of the box.
Though, obviously, it is only for apache, so forget about it if your host or you are using NGINX or something
Well, you could have always tried Google Webmater Tools and setting which you wanted to be indexed (with or without www) in google. But, if it's al problem - apache rewrites are a fair SEO get-around for it.
-
08-16-2011, 09:40 AM #5
I use it for all sites. It's true www. is subdomain. Main domain and subdomains rank separately. No good getting linkbacks for main domain and subdomain. It's best to get all linksbacks for one or the other.
HostXNow - Shared Web Hosting | Semi Dedicated Hosting | Enterprise Reseller Hosting | VPS Hosting
-
08-16-2011, 10:16 AM #6Junior Guru Wannabe
- Join Date
- Jun 2011
- Posts
- 36
Very helpful for new comers indeed, especially the ones that often switch their content.
<< Please see the Rules page for signature limitations. >>
Similar Threads
-
301 redirect root to subfolder as well as www to subfolder
By Jaffery in forum SEO / SEM DiscussionsReplies: 5Last Post: 05-08-2012, 07:39 AM -
How to 301 Redirect Non-WWW to WWW URLs is all domians in server ???
By sasky in forum Hosting Security and TechnologyReplies: 5Last Post: 07-27-2010, 10:58 AM -
301 Redirects to www.domain w/ ISAPI_Rewrite
By EVILISCIOUS in forum Programming DiscussionReplies: 3Last Post: 09-21-2006, 10:26 AM -
How to redirect http://www.example.com/index.php to http://www.example.com?
By grabmail in forum Programming DiscussionReplies: 13Last Post: 08-20-2006, 08:58 AM -
www.t63.net / www.usaflights.us/www.legalqueries.com - All bids considered
By myself1982 in forum Domain Name OffersReplies: 2Last Post: 08-16-2004, 11:22 AM