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. Redirect www.domain to domain

    Redirect www.domain to domain

    On-Page / Site Optimization
    6 6 104
    • 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.
    • entrepreneurhandbook
      entrepreneurhandbook last edited by

      How do I redirect www.entrepreneurhandbook.co.uk to entrepreneurhandbook.co.uk

      The latter is an existing site.

      Thanks

      James

      1 Reply Last reply Reply Quote 1
      • sparkeeey
        sparkeeey last edited by

        <code>Add the following to the.htaccess file in the root directory of your site</code>
        
        RewriteEngine On
        RewriteBase /
        RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
        RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
        
        DonnaDuncan 1 Reply Last reply Reply Quote 0
        • triggertrap
          triggertrap last edited by

          Alternatively:

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

          Windows Server/IIS:

          • Start Internet Services Manager. or start the IIS Snap-in in Microsoft Management Console (MMC).

          • Click to expand * server name, where server name is the name of the server.

          • Right-click either the Web site or the folder that you want to redirect, and then click Properties.

          • Click one of the following tabs that is appropriate to your situation:

          • Home Directory

          • Virtual Directory

          • Directory

          • Under When connecting to this resource, the content should come from, click A redirection to a URL.

          • Type the URL of the destination folder or Web site in the Redirect to box.

          For example, to redirect all requests for files located at www.mycompany.com to mycompany.com type http://mycompany.com

          • Click OK.
          Vizergy 1 Reply Last reply Reply Quote 1
          • DonnaDuncan
            DonnaDuncan @sparkeeey last edited by

            It can be a bit tricky.

            This short and simple how to might help.

            http://kb.mediatemple.net/questions/242/How+do+I+redirect+my+site+using+a+.htaccess+file%3F

            1 Reply Last reply Reply Quote 0
            • David-Kley
              David-Kley last edited by

              force non-www

              RewriteCond %{HTTP_HOST} ^entrepreneurhandbook.co.uk$ [OR]
              RewriteCond %{HTTP_HOST} ^www.entrepreneurhandbook.co.uk$
              RewriteRule ^/?$ "http://entrepreneurhandbook.co.uk/" [R=301,L]

              Add the code listed above to your HTACESS file. This version will redirect both versions to the non-www version. The hashtag won't matter if you have that in there, that is for labeling your redirects. Makes navigating your HTACCESS file a lot easier.

              1 Reply Last reply Reply Quote 0
              • Vizergy
                Vizergy @triggertrap last edited by

                Good job covering Windows as well as Linux.  🙂

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                • Domain Redirection
                  Roman-Delcarmen
                  Roman-Delcarmen
                  0
                  3
                  78

                • Redirecting to new domain
                  MattAntonino
                  MattAntonino
                  0
                  3
                  99

                • Redirecting a Parked Domain
                  ThompsonPaul
                  ThompsonPaul
                  0
                  3
                  352

                • Www redirect
                  thomasfasting
                  thomasfasting
                  0
                  4
                  337

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

                • Redirect sub domain to domain in .htaccessU
                  rasmusbang
                  rasmusbang
                  0
                  4
                  496

                • Domain.com and www.domain.com
                  ChristopherGlaeser
                  ChristopherGlaeser
                  0
                  4
                  828

                • Necessary to redirect non-www to www?
                  RavenshoeGroup
                  RavenshoeGroup
                  0
                  4
                  2.1k

                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