The best way to redirect to www
-
What is the best way to redirect non www to www. I saw a lot of the solution. is this one ok?
RewriteCond %{HTTP_HOST} !^www.seomoz.org [NC]
RewriteRule (.*) http://www.seomoz.org/$1 [L,R=301]
-
Glad you got it. The code I like to use:
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]Of course, replacing "domain" with your own domain.
Let us know if you need any more help.
-
yes, a lot of people don't know that you should verify both the www and non www version of your site in Google Webmaster Tools!
-
This works:
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
and to select preferred domain name first I need to add non www version of the website and that's why I received an error.
You help me a lot!
-
What is the server error you are getting with the .htaccess file?
You do indeed need to verify ownership of you site, it's real easy to do, it involves adding a small piece of code to your site. See http://support.google.com/webmasters/bin/answer.py?hl=en&answer=35179 -
I got server error with .htaccess file and in webmaster tool message "Part of the process of setting a preferred domain is to verify that you own http://
-
That solution works just fine.
It looks like the one from the SEOmoz "Redirection SEO Best Practices"
I've never had any problems with it.
Also to keep things tidy, be sure to tell Google Webmaster Tools that your preferred domain is **www.**domain.com
GWMT -> configuration -> settings -> display URL's as www.domain.com
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Update old article or publish new content and redirect old post?
Hi all, I'm targetting a keyword and we used to rank quite good for it. Last couple of months traffic of that keyword (and variations) is going down a bit. I wrote an extensive new post on the same topic, much more in dept and from 600 to 1800 words covering the same topic. Is it better to update the old article and mention that it's updated recently, or publish a new post and redirect the old post to the new post?
On-Page Optimization | | jorisbrabants0 -
Should I Redirect My Subdomain Or Not?
Hi everyone, I have a question regarding my subdomain. My website is japracool[dot]com and it was under coriate[dot]com (in my hosting service). I still can access my website trough japracool[dot]coriate[dot]com. My question, should I redirect it to japracool[dot]com? Thanks before.
On-Page Optimization | | Japracool0 -
Best practices for marking up product pages on eccomerce site (SEO noob)
After analyzing the code on various competitors eccomerce sites I wanted to seek advice on best practices for marking up individual product pages for keywords and descriptions. My competition is all over the map as far as utilizing keywords and descriptions, some have few keywords while others have many and vice versa for descriptions. What is the best method for marking up product pages on an eccomerce site for keywords and descriptions? In addition, is it okay to utilize the same keywords for multiple products that may be under the same category? or is this considered duplicate content? Thanks for the help, if you have any resources for SEO and eccomerce sites I would greatly appreciate the guidance best,Michelle & Blake
On-Page Optimization | | LeapOfBelief0 -
Is it redundant to include a redirect to my canonical domain (www) in my .htaccess file since I already have the correct rel="canonical" in my header?
I've been reading the benefits of each practice, but not found anyone mentioning whether it's really necessary to do both? Personally I try to stay clear of .htaccess rewrites unless it's absolutely necessary, since because I've read they can slow down a website.
On-Page Optimization | | HOPdigital0 -
Multiple Sizes of eCommerce Product Best Practice
I sell a product that comes in 9 different sizes, two materials, and two different shapes. People often search for this product by size, material and shape as follows: #9 material1 square widget #5 material2 circle widget The dilemma I'm facing is should I create 1 page for each of these products resulting in 36 different pages, or should I create one page that the users can select size shape and material? I'm thinking that from a usability stance, the 36 different pages are easier to navigate and determine price on, but I'm afraid that going the route that is easier for the customer to use in this case could hurt me duplicate content wise. I'm all about making a good user experience, but don't want to hurt myself because the content on all 9 sizes is basically the same. Are images of the product enough to be considered non-duplicate content? I also list out the dimensions of each product, but beyond that there isn't much to delineate the content. My plan is to create one page with all the content that relates to all of the products as a top level page with links to the individual products broken down, but just wanted to get some feedback from you guys before making the effort.
On-Page Optimization | | kadesmith0 -
How do I switch my website to www.mydomain?
I'm having canonical URL problems. I keep trying to set everything to www.mydomain.com, but I'm using wordpress and my site keeps either disappearing completely or giving me an infinite loop error. I've tried changing my main wordpress setting, whether I have canonical URLs turned on, my .htaccess file... Could this be an issue with either my host or my domain registrar? Any ideas how I can fix it?
On-Page Optimization | | lauragee0 -
Login Page Redirection
Hello, I have certain pages on my site which are login only. Am wondering if a user reaches that page, should I send him to a 301 redirect to a new login page? or some other form of redirection? Any suggestions on how to best tackle this situation? Update If I redirect to a login.php page, then what kind of redirection should I use? Thank you for your time, Anant
On-Page Optimization | | anantgarg0 -
301 redirect (www.domain.com/index to www.domain.com)
Hello, Please let me know what are the exact right steps in order to get rid of the duplicate content issues related with: www.domain.com/index.html same as www.domain.com without creating an infinite loop. Do you have a step by step guide posted within seomoz including 301 redirect for non www to www for all urls and index.whatever to main domain name without going into a infinite loop ? btw how to you spot the loop ? is it obvious like never ending refresh of the home page ? thanks a lot !
On-Page Optimization | | eyepaq2