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. Htaccess rewrite rule (very specific)

    Htaccess rewrite rule (very specific)

    Intermediate & Advanced SEO
    4 3 118
    • 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.
    • Waismann
      Waismann last edited by

      Hello,

      Awhile back my company changed from http: to https: sitewide (before i started working here). We use a very standard rewrite rule that looks like this:

      RewriteEngine On
      RewriteCond %{SERVER_PORT} 80
      RewriteRule ^(.*)$ https://opiates.com/$1 [R,L]

      However, with this rule in place, some http: urls are being redirected with a 302 status code. My question is, can I safely change the above code to look like this:

      RewriteEngine On
      RewriteCond %{SERVER_PORT} 80
      RewriteRule ^(.*)$ https://opiates.com/$1 [R=301,L]

      to ensure that every redirected is returned with a 301 status code. The only change is in the [R,L] section. Thanks to whomever can help with this. I'm pretty sure its safe but I dont want the site to go down, even for a second, so figured I would ask first.

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

        That's perfectly fine.

        irvingw 1 Reply Last reply Reply Quote 1
        • WilliamKammer
          WilliamKammer last edited by

          This should work out just fine. If you want to confirm that it is effective, you can backup the old htaccess, upload the new one, go to one of the previously 302'd pages and see if it 301s now. You can check this using the network tab in Chrome's developer tools.

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

            Just one more note:

            You have a Double Redirect and you should write your Rewrite rules to avoid this double redirect as each redirect will cause some loss of page juice.

            Checked link: http://www.opiates.com/

            Type of redirect: 301 Moved Permanently

            Redirected to: http://opiates.com/

            2.

            Checked link: http://opiates.com/

            Type of redirect: 302 Found

            Redirected to: https://opiates.com/

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            • 6 .htaccess Rewrites: Remove index.html, Remove .html, Force non-www, Force Trailing Slash
              roynguyen
              roynguyen
              0
              4
              9.7k

            • I've seen and heard alot about city-specific landing pages for businesses with multiple locations, but what about city-specific landing pages for cities nearby that you aren't actually located in? Is it ok to create landing pages for nearby cities?
              AlanMosley
              AlanMosley
              1
              3
              1.9k

            • .htaccess 301 Redirect Help! Specific Redirects and Blanket Rule
              LynnPatchett
              LynnPatchett
              0
              3
              3.1k

            • .htaccess newby
              GlobalLingo
              GlobalLingo
              0
              16
              334

            • Rewriting URL
              corwin
              corwin
              0
              3
              253

            • .htaccess files
              JamesFx
              JamesFx
              0
              4
              294

            • Modify .htaccess
              Highland
              Highland
              0
              10
              466

            • How can I change my website's content on specific pages without affecting ranking for specific keywords?
              Thos003
              Thos003
              0
              3
              818

            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