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. Warning about a 302 redirect

    Warning about a 302 redirect

    Intermediate & Advanced SEO
    2 2 353
    • 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.
    • stevenpicado
      stevenpicado last edited by

      Hello everyone,

      I'm testing the pro software and recently I installed an SSL Certificate on one of the websites I'm monitoring, I put in place an .htaccess directive to force all traffic to the secure version of the site (https) and I noticed how this raised a warning because my directive is forcing the traffic with a 302 redirect.

      These are the lines:

      _RewriteCond %{SERVER_PORT} 80 _

      RewriteRule ^(.*)$ https://example.com/$1 [R,L]

      I understand that this is not good so I figured since I'm already redirecting all www to -www I can force traffic that arrives trying to use www to the secure version like so:

      RewriteCond %{HTTP_HOST} !^example.com$

      RewriteRule (.*) https://example.com/$1 [R=301,L]

      But this is not 100% effective because if someone visits the site directly on the -www version this person wont get redirected hence it wont be forced to see the https.

      So my question is: does anybody know of an alternate way to force traffic to the secure socket using a 301 instead of a 302?

      Oh boy, just by writing the question I think I may have figured it out, I'll post it anyways because (1) I could be wrong and (2) It could help someone else.

      It just hit me but the directive that is forcing www to -www specifies what type of redirect to do here [R=301,L].

      So to try to answer my own question before even posting it this could probably do the trick:

      _RewriteCond %{SERVER_PORT} 80 _

      _RewriteRule ^(.*)$ https://example.com/$1 [_R=301,R,L]

      I'll be testing it out ASAP and again I'll post the question anyways just in case it doesn't work, in case someone has a good suggestion or to help someone that could be in the same situation.

      If this is turns out right I will need someone to slap me in the face 😐

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

        Hi Steven,

        Don't you just love that moment when you realize that you were clever enough to figure out the answer without help from anyone else?

        Very nice of you to "take one for the team"  by leaving the post to help others who might follow in your footsteps 🙂

        Sha

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        • 302 > 302 > 301 Redirect Chain Issue & Advice
          Everett
          Everett
          0
          3
          583

        • Going from 302 redirect to 301 redirect weeks after changing URL structure
          vcj
          vcj
          0
          2
          131

        • If you do 302 redirect then change to 301 redirect do you lose all link juice?
          EricaMcGillivray
          EricaMcGillivray
          0
          3
          792

        • To redirect or not to redirect, that is the question
          CommT
          CommT
          0
          5
          126

        • Redirecting a redirect - thoughts?
          MikeRoberts
          MikeRoberts
          0
          2
          165

        • Redirecting, then redirecting back
          Highland
          Highland
          0
          2
          256

        • Login redirect 302
          Anthony_NorthSEO
          Anthony_NorthSEO
          0
          9
          2.3k

        • 302 redirect
          joseph.chambers
          joseph.chambers
          0
          2
          487

        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