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. Moz Tools
    4. Bad code on Learn Seo Redirection info Page

    Bad code on Learn Seo Redirection info Page

    Moz Tools
    3 2 566
    • 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.
    • squareplug
      squareplug last edited by

      Is it just me, or is the Redirection resource page missing the exclamation point (!) in this code. If so, this could really mess someone's site up if they copy and paste.

      http://www.seomoz.org/learn-seo/redirection

      http://screencast.com/t/n7lknZ32G9xF

      Redirecting Canonical Hostnames: The original developers at SEOmoz needed to redirect any requests that do not start with www.seomoz.org to make sure they included the www. They did this not only because it looks better, but to avoid common canonicalization errors. Redirect: http://seomoz.org/To: http://www.seomoz.org/ Redirect: http://mail.seomoz.org/To: http://www.seomoz.org Redirect: http://seomoz.org/somefile.phpTo: http://www.seomoz.org/somefile.php Solution: Add the following directive: RewriteCond %{HTTP_HOST} ^seomoz.org [NC]RewriteRule (.*) http://www.seomoz.org/$1 [L,R=301] Explanation: This directive tells apache to examine the host the visitor is accessing (in this case: seomoz.org), and if it does not equal www.seomoz.org redirect  to www.seomoz.org. The exclamation point (!) in front of www.seomoz.org negates the comparison, saying “if the host IS NOT www.seomoz.org, then perform RewriteRule.” In our case RewriteRule redirects them to www.seomoz.org while preserving the exact file they were accessing in a back-reference.

      *emphasis added by me

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

        Hi Holly,

        Good catch. The code should look like:

        RewriteCond %{HTTP_HOST} !^www.seomoz.com$ [NC]
        RewriteRule ^(.*)$ http://www.domain.com/$1 [R,L]

        Explanation:

        This directive tells apache to examine the host the visitor is accessing. If it does not equal www.seomoz.org, redirect  to www.seomoz.org. The exclamation point (!) in front of ^www.seomoz.org negates the comparison, saying “if the host IS NOT www.seomoz.org, then perform RewriteRule.” In our case RewriteRule redirects them to www.seomoz.org while preserving the exact file they were accessing in a back-reference.

        I'll send a note to our help team to get this fixed.

        Thanks!

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

          I think I'm becoming anal retentive. Just today, I took the time to contact two "seo" companies with linked articles from the Learn Seo page to let them know that they might want to redirect their broken links! I can't imagine having a link like that and letting it just crumble in to little 1s and 0s, not to mention I didn't get the info I was wanting. I'm sure they'll think I'm nuts. I then start thinking to myself, "self, you might know a thing or two" and then another robot and his tag issue come whack me back in my place...

          thanks for the confirmation Cyrus. I just found out there's a support forum for this kind of thing..probably a better place for these  issues.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          • Find 28 pages (status code 200) on MOZ Pro but 8 on Screaming Frog SEO Spider 11.3
            effectdigital
            effectdigital
            0
            3
            52

          • Redirects, SEO and More
            RuthBurrReedy
            RuthBurrReedy
            0
            3
            185

          • 301 Redirects - Page Authority Not Transferring
            genkee
            genkee
            1
            6
            2.3k

          • Seo moz has only crawled 2 pages of my site. Ive been notified of a 403 error and need an answer as to why my pages are not being crawled?
            nitro-digital
            nitro-digital
            0
            9
            319

          • How long will it take for Page Rank (or Page Authority) to flow via a 301 redirect?
            annomd
            annomd
            0
            3
            660

          • Where to learn SEO practices, especially local
            jonrognerud
            jonrognerud
            0
            4
            361

          • 4xx status code a page that cannot be accessed..
            ChiarynMiranda
            ChiarynMiranda
            0
            2
            394

          • My website has 18500 pages but my SEO MOZ campaign is limited to a 10,000 page crawl. How can I get the other 8500 pages crawled? Can I use one of my 3 spare campaigns?
            kenneth_martin
            kenneth_martin
            0
            5
            1.0k

          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