The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. On-Page / Site Optimization
    4. The best way to redirect to www

    The best way to redirect to www

    On-Page / Site Optimization
    7 4 336
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • bruki
      bruki last edited by

      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]

      1 Reply Last reply Reply Quote 0
      • JustinTaylor88
        JustinTaylor88 last edited by

        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

        bruki 1 Reply Last reply Reply Quote 0
        • bruki
          bruki @JustinTaylor88 last edited by

          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://

          JustinTaylor88 bruki irvingw Cyrus-Shepard 4 Replies Last reply Reply Quote 0
          • JustinTaylor88
            JustinTaylor88 @bruki last edited by

            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

            1 Reply Last reply Reply Quote 0
            • bruki
              bruki @bruki last edited by

              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!

              1 Reply Last reply Reply Quote 1
              • irvingw
                irvingw @bruki last edited by

                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!

                1 Reply Last reply Reply Quote 0
                • Cyrus-Shepard
                  Cyrus-Shepard @bruki last edited by

                  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.

                  1 Reply Last reply Reply Quote 1
                  • 1 / 1
                  • First post
                    Last post
                  • What is the best way to change keywords?
                    jonnyholt
                    jonnyholt
                    0
                    4
                    78

                  • What is the best way to execute a geo redirect?
                    FedeEinhorn
                    FedeEinhorn
                    0
                    4
                    738

                  • 301 redirect www.brandname.com to www.brandname-keyword.com
                    Webrevolve
                    Webrevolve
                    0
                    8
                    583

                  • Best way to do a 301 redirect when the incorrect page has rank and FB likes
                    foodsleuth
                    foodsleuth
                    0
                    5
                    331

                  • Www redirect
                    thomasfasting
                    thomasfasting
                    0
                    4
                    337

                  • Too www. or not to www.?
                    ClassifiedsKing
                    ClassifiedsKing
                    0
                    4
                    844

                  • How do I do a 301 Redirect in IIS 7 from http://www.freightmonster.com/index.html to http://freightmonster.com/index.html when I don't have a physical page to redirect?
                    EricaMcGillivray
                    EricaMcGillivray
                    0
                    4
                    1.0k

                  • What's the Best Way to Hide Redirects from Search Engines?
                    JaredB
                    JaredB
                    0
                    8
                    867

                  Get started with Moz Pro!

                  Unlock the power of advanced SEO tools and data-driven insights.

                  Start my free trial
                  Products
                  • Moz Pro
                  • Moz Local
                  • Moz API
                  • Moz Data
                  • STAT
                  • Product Updates
                  Moz Solutions
                  • SMB Solutions
                  • Agency Solutions
                  • Enterprise Solutions
                  • Digital Marketers
                  Free SEO Tools
                  • Domain Authority Checker
                  • Link Explorer
                  • Keyword Explorer
                  • Competitive Research
                  • Brand Authority Checker
                  • Local Citation Checker
                  • MozBar Extension
                  • MozCast
                  Resources
                  • Blog
                  • SEO Learning Center
                  • Help Hub
                  • Beginner's Guide to SEO
                  • How-to Guides
                  • Moz Academy
                  • API Docs
                  About Moz
                  • About
                  • Team
                  • Careers
                  • Contact
                  Why Moz
                  • Case Studies
                  • Testimonials
                  Get Involved
                  • Become an Affiliate
                  • MozCon
                  • Webinars
                  • Practical Marketer Series
                  • MozPod
                  Connect with us

                  Contact the Help team

                  Join our newsletter
                  Moz logo
                  © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
                  • Accessibility
                  • Terms of Use
                  • Privacy