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. Technical SEO Issues
    4. How to change 302 redirect from http to https

    How to change 302 redirect from http to https

    Technical SEO Issues
    4 3 2.1k
    • 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.
    • davedon
      davedon last edited by

      Hi gang. Our site currently has a 302 redirect from the HTTP version of the homepage to the HTTPS version of the homepage. I understand this really should be changed to a 301 redirect but I'm having a little trouble figuring out exactly how this should be done.

      Some places on the internet are telling me I can edit our htaccess file to specify the type of redirect, however our htaccess file seems to be missing some of the information in theirs.

      Can anyone tell me what needs to be changed in the htaccess file - or if there's a simpler way to change the 302 to a 301? Many thanks 🙂

      htaccess:

      BEGIN WordPress

      RewriteEngine On

      RewriteBase /

      RewriteRule ^index.php$ - [L]

      RewriteCond %{REQUEST_FILENAME} !-f

      RewriteCond %{REQUEST_FILENAME} !-d

      RewriteRule . /index.php [L]

      END WordPress

      EXPIRES CACHING

      ExpiresActive On

      ExpiresByType image/jpg "access plus 6 months"

      ExpiresByType image/jpeg "access plus 6 months"

      ExpiresByType image/gif "access plus 6 months"

      ExpiresByType image/png "access plus 6 months"

      ExpiresByType text/css "access plus 10 days"

      ExpiresByType application/pdf "access plus 10 days"

      ExpiresByType application/x-shockwave-flash "access plus 10 days"

      ExpiresByType image/x-icon "access plus 6 months"

      ExpiresDefault "access plus 2 days"

      EXPIRES CACHING

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

        Hi Use the following

        `# Redirect all "not correct" domain to www with https
        
        # (is not important if comes with or without https):
        
        RewriteCond %{HTTP_HOST} !^www.example.co.uk$ [NC]
        
        RewriteRule ^(.*)$ https://www.example.co.uk/$1 [L,R=301]
        
        # Redirect all non-ssl to ssl.
        
        RewriteCond %{HTTPS} off
        
        RewriteRule ^(.*)$ https://www.example.co.uk/$1 [R,L]` 
        
        
        davedon 1 Reply Last reply Reply Quote 1
        • MattRoney
          MattRoney last edited by

          Hi David! Did Ikkie's response do the trick? 🙂

          1 Reply Last reply Reply Quote 0
          • davedon
            davedon @Mustansar last edited by

            Oop hi Ikkie, thanks for responding and sorry I didn't. Been one of those weeks!

            When I tried this I got the following error: 'www.midlandnetworks.co.uk redirected you too many times.' Do I need to replace the first bit of my htaccess with that or just stick it on the end? Sticking on the end didn't seem too successful for me.

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            • Switched from and HTTPS to HTTP. My home page is facing a redirect issue from the http to https. Should I no index the HTTP or find the redirect and delete it? Thank you
              LandmarkRecovery2017
              LandmarkRecovery2017
              0
              3
              42

            • Our site recently switched from http to https. Do I still need to setup a redirect for the incoming links pointing to http?
              Andy.Drinkwater
              Andy.Drinkwater
              0
              5
              81

            • Http -> https redirections / 301 the right way
              Andy.Drinkwater
              Andy.Drinkwater
              0
              4
              61

            • Http:// to https:// 301 or 302 redirect
              Kingof5
              Kingof5
              1
              7
              284

            • 302 Redirect from HTTP to HTTPS
              corwin
              corwin
              0
              2
              486

            • Best method of redirecting http to https on homepage
              Dr-Pete
              Dr-Pete
              0
              7
              1.0k

            • 302 or 301 redirect to https ?
              Kotkov
              Kotkov
              0
              9
              33.6k

            • Worth Changing Redirect From 302 to 301?
              dawnieando
              dawnieando
              0
              7
              832

            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