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. Intermediate & Advanced SEO
    4. 301 Redirect All Url's - WWW -> HTTP

    301 Redirect All Url's - WWW -> HTTP

    Intermediate & Advanced SEO
    4 2 693
    • 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.
    • DustinX
      DustinX last edited by

      Hi guys,

      This is part 2 of a question I asked before which got partially answered; I clicked question answered before I realized it only fixed part of the problem so I think I have to post a new question now.

      I have an apache server I believe on Host Gator. What I want to do is redirect every URL to it's corresponding alternative (www redirects to http). So for example if someone typed in www.mysite.com/page1 it would take them to http://mysite.com/page1

      Here is a code that has made all of my site's links go from WWW to HTTP which is great, but the problem is still if you try to access the WWW version by typing it, it still works and I need it to redirect. It's important because Google has been indexing SOME of the URL's as http and some as WWW and my site was just HTTP for a long time until I made the mistake of switching it now I'm having a problem with duplicate content and such. Updated it in Webmaster Tools but I need to do this regardless for other SE's. Thanks a ton!

      RewriteEngine On
      RewriteBase /
      RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
      RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
      
      
      1 Reply Last reply Reply Quote 0
      • Thos003
        Thos003 last edited by

        How long has the rewrite been up?  You can try this page: http://www.ragepank.com/redirect-check/

        DustinX 2 Replies Last reply Reply Quote 1
        • DustinX
          DustinX @Thos003 last edited by

          Thank you. That brought forth another problem which is the index.php page being a seemingly separate entity than just the standard URL. Going to have to redirect that too, although I have an E-commerce store and it ends up generating session ID's and such in the URL so I have to figure out how to redirect anything with index.php and that's true for the main URL too I believe.

          The biggest issue though still is the WWW versions being accessible.

          1 Reply Last reply Reply Quote 0
          • DustinX
            DustinX @Thos003 last edited by

            Rewrite has been up for a few hours now by the way, I'm going to look through the file because I use a branch of Oscommerce and there are a lot of URL appending things and such so there may be something negating the 301 code I was given to do the redirects

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            • We are redirecting http and non www versions of our website. Should all versions http (non www version and www version) and https (non www version) should just have 1 redirect to the https www version?
              BlueprintMarketing
              BlueprintMarketing
              0
              8
              437

            • Migrating From Parameter-Driven URL's to 'SEO Friendly URL's (Slugs)
              PatrickDelehanty
              PatrickDelehanty
              0
              2
              292

            • Will disallowing URL's in the robots.txt file stop those URL's being indexed by Google
              Martijn_Scheijbeler
              Martijn_Scheijbeler
              0
              11
              1.6k

            • Does Google Read URL's if they include a # tag? Re: SEO Value of Clean Url's
              Atlanta-SMO
              Atlanta-SMO
              0
              6
              1.6k

            • Effect SERP's internal 301 redirects?
              Chris.Menke
              Chris.Menke
              1
              3
              256

            • How to do a 301 redirect for url's with this structure?
              Matthew_Edgar
              Matthew_Edgar
              0
              2
              287

            • Should I 301 Poorly Worded URL's which are indexed and driving traffic
              RobertFisher
              RobertFisher
              0
              2
              478

            • Best solution to get mass URl's out the SE's index
              James77
              James77
              0
              3
              583

            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