The Moz Q&A Forum

    • Forum
    • Questions
    • 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 Forum
    2. Categories
    3. Research & Trends
    4. SERP Trends
    5. 302 redirect on http but not on https

    Moz Q&A is closed.

    After more than 13 years, and tens of thousands of questions, Moz Q&A closed on 12th December 2024. Whilst we’re not completely removing the content - many posts will still be possible to view - we have locked both new posts and new replies. More details here.

    302 redirect on http but not on https

    SERP Trends
    10 4 12.2k
    • 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.
    • Direct_Ram
      Direct_Ram last edited by

      Hi

      I have noticed using screaming frog that 302 redirect is in place but when checking the HTTACESS there no such thing in place.

      If I run a scan with: http://www.redirect-checker.org/index.php doing a test with: https://www. everything seems ok but then when I do: http://www. There is a 302 in place and seem to understand why.

      I have analysed the Httacess file and cant seem to locate anything that refers to the 302 any advise or previous experience would be great.

      Thanks
      E

      1 Reply Last reply Reply Quote 0
      • BlueprintMarketing
        BlueprintMarketing @Direct_Ram last edited by

        you're running Apache tomcat right?

        301 Redirect URLs.

        Redirect 301 /holidays/about-direct-traveller/british-travel-awards.asp /directtraveller/awards
        Redirect 301 /directtraveller/holidays/about-direct-traveller/british-travel-awards.asp /directtraveller/awards

        I am guessing this simply from you having this port open and having no issues with HTaccess 8443 is the default port of tomcat with ssl

        http://beamusup.com/generate-htaccess/

        1 Reply Last reply Reply Quote 0
        • BlueprintMarketing
          BlueprintMarketing @TheWebMastercom last edited by

          Johnson I agree thumbs up with Nginx could definitely be a as reverse proxy. the best way to tell would be to scan the ports but I will allow him to do that.

          I agree with you as well on the 302 issue

          He has to redirect using a 301 instead of a 302 from

          https://www.directtraveller.com/holidays/about-direct-traveller/british-travel-awards.asp

          https://www.directtraveller.com/awards
           I bet there are a few other 302's in there if there are one however I'm speculating. Crawling the site withhttps://www.deepcrawl.com/ or http://www.screamingfrog.co.uk/seo-spider/ will show him any 302's as far as the best way to redirect I agree with you again it is based on what type of server he is using.

          If MS ASP

          Ues

          http://www.rapidtables.com/web/tools/redirect-generator.htm

          http://www.rapidtables.com/web/dev/url-redirect.htm#asp-redirect

          ASP redirect

          old-page.asp:

          <%@ Language="VBScript" %>
          <%
          ' ASP permanent URL redirection
          Response.Status="301 Moved Permanently"
          Response.AddHeader "Location", "http://www.mydomain.com/new-page.html"
          Response.End
          %>

          http://ask.webatall.com/nginx/17733_nginx-redirect-http-to-https-and-non-www-to-ww.html

          From feed the bot you can see your site is unfortunately using 302's maybe that's on purpose if not you should change it to 301's.

          Final status code: 200
          1 Redirect(s)
          https://www.directtraveller.com/holidays/about-direct-traveller/british-travel-awards.asp 
          ** 302 redirect**
          https://www.directtraveller.com/awards

          If is is a Proxy

          http://wiki.nginx.org/HttpProxyModule#proxy_redirect

          http://wiki.nginx.org/Pitfalls#Using_If

          PS

          I would remove the nofollow on these links. Google likes TOS and privacy policies

          Nofollow links

          3 nofollow links

          • /terms-and-conditions
          • /resources
          • /privacy-policy  checked using http://www.feedthebot.com/tools/

          all the best,

          Tom

          1 Reply Last reply Reply Quote 0
          • Direct_Ram
            Direct_Ram @TheWebMastercom last edited by

            We have a redirect from HTTP to HTTPS and then have the following redirect on the httaccess file:

            #Redirect /directtraveller/holidays/about-direct-traveller/british-travel-awards.asp /directtraveller/awards

            Redirect /holidays/about-direct-traveller/british-travel-awards.asp /directtraveller/awards

            BlueprintMarketing 1 Reply Last reply Reply Quote 0
            • TheWebMastercom
              TheWebMastercom @BlueprintMarketing last edited by

              Not necessarily.  He could be using Nginx as reverse proxy.

              He already said the http to https is working fine with my suggestion.  The problem is the redirect from one URL to another which what I gave him for the .htaccess doesn't address at all.

              ie.

              https://www.directtraveller.com/holidays/about-direct-traveller/british-travel-awards.asp
              to
              https://www.directtraveller.com/awards

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

                The reason why the HTaccess file is not working for you is because you're running a server on Nginx instead of Apache's .htaccess  your server uses a "nginx config" this is why .htaccess   will not work properly. this will also show you why you're still running a 302 redirect instead of a 301 redirect

                http://www.redant.com.au/ruby-on-rails-devops/manage-ssl-redirection-in-nginx-using-maps-and-save-the-universe/

                https://www.digitalocean.com/community/questions/http-https-redirect-positive-ssl-on-nginx

                for referencing these URLs below will tell you everything you need to know about your configuration and how to set it up. I've placed a lot of redirects below because there are so many different ways of doing this below the two URLs where it says I recommend using this is the configuration that should be default on your server in order to force SSL

                http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#return

                http://nginx.org/en/docs/http/ngx_http_core_module.html#server_name

                ** I recommend using this to fix use this on your nginx config file**

                _**`server {
                       listen         80;
                       server_name    www.domain.com;
                       return         301 https://$server_name$request_uri;
                }
                
                server {
                       listen         443 ssl;
                       server_name    www.domain.com;
                
                       [....]
                }`**_
                

                might be easier this way

                <code>server {
                       listen         80;
                       server_name    my.domain.com;
                       return         301 https://$server_name$request_uri;
                }
                
                server {
                       listen         443 ssl;
                       server_name    my.domain.com;
                
                       [....]
                }</code>
                

                you are still putting out 302's I double checked your server

                http://www.feedthebot.com/tools/headers/test.php

                https://www.directtraveller.com/holidays/about-direct-traveller/british-travel-awards.asp

                HTTP/1.1 **302 Found **
                Server: nginx/1.6.0 
                Date: Sat, 11 Apr 2015 02:59:23 GMT 
                Content-Type: text/html; charset=iso-8859-1 
                Connection: keep-alive 
                Location: https://www.directtraveller.com/awards

                Header transfer size: 199

                http://www.directtraveller.com/holidays/about-direct-traveller/british-travel-awards.asp


                301 Moved Permanently

                | Status: | 301 Moved Permanently |
                | Code: | 301 |
                | Server: | nginx/1.6.0 |
                | Date: | Sat, 11 Apr 2015 02:12:51 GMT |
                | Content-Type: | text/html; charset=iso-8859-1 |
                | Content-Length: | 370 |
                | Connection: | close |
                | Location: | https://www.directtraveller.com/holidays/about-direct-traveller/british-travel-awards.asp |

                https://www.directtraveller.com/holidays/about-direct-traveller/british-travel-awards.asp


                302 Found

                | Status: | 302 Found |
                | Code: | 302 |
                | Server: | nginx/1.6.0 |
                | Date: | Sat, 11 Apr 2015 02:12:51 GMT |
                | Content-Type: | text/html; charset=iso-8859-1 |
                | Content-Length: | 296 |
                | Connection: | close |
                | Location: | https://www.directtraveller.com/awards

                |

                | Status: | 200 OK |
                | Code: | 200 |
                | Server: | nginx/1.6.0 |
                | Date: | Sat, 11 Apr 2015 02:12:52 GMT |
                | Content-Type: | text/html |

                you can convert Htaccess to  nginx using this tool http://winginx.com/en/htaccess

                however I would force SSL instead of use a rewrite through the converter. The redirects below work but I would use the server-side redirect labeled use this

                Check out Engine Yard for more redirects I have placed quite a few here

                https://blog.engineyard.com/2011/useful-rewrites-for-nginx

                this is a basic redirect you can put the port or each port in place.

                server {
                server_name example.com;
                rewrite ^/(.*) https://example.com/$1 permanent;
                }

                USE THIS

                Redirect both, non-SSL and SSL to their www counterpart:

                <code>**server {
                    listen 80;
                    listen 443 ssl;
                    server_name directtraveller.com;
                    return 301 $scheme://www.directtraveller.com$request_uri;
                }**
                
                server {
                    listen 80;
                    listen 443 ssl;
                    server_name example.com;
                    # rest goes here...
                }</code> 
                

                Add a www with this block

                server {
                listen 80;

                listen 443 ssl;

                server_name directtraveller.com;
                rewrite ^(.*)$ $scheme://www.directtraveller.com$1;
                }

                (

                )

                Remove a www with this block instead

                server {
                listen 80;
                server_name www.directtraveller.com;
                rewrite ^(.*)$ $scheme://directtraveller.com$1;
                }

                <code>rewrite ^(.*)$ https://$host$1 permanent; #3
                rewrite ^ https://$host$request_uri permanent; #4
                
                I**f you have any questions please feel free to ask I hope this is enough information and not overwhelming. If you feel overwhelmed simply use the very first config.**
                
                 **Sincerely,**
                 **Tom**</code>
                
                TheWebMastercom 1 Reply Last reply Reply Quote 0
                • TheWebMastercom
                  TheWebMastercom last edited by

                  What did you put to redirect the following:

                  https://www.directtraveller.com/holidays/about-direct-traveller/british-travel-awards.asp
                  to
                  https://www.directtraveller.com/awards

                  As that is where the problem lies.

                  Direct_Ram 1 Reply Last reply Reply Quote 0
                  • Direct_Ram
                    Direct_Ram @TheWebMastercom last edited by

                    John threw that in and did a retest and is working now - you genius! Thanks

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

                      Hi Ram. If Jon's fix above doesn't work, you might want to post the link(s) you're testing with Screaming Frog so that people here can see what's going on and give you specific recommendations. It sounds like there's a 302 in place on the http version of your site, but people will need details to see where exactly. Cheers!

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

                        Try this in your .htaccess file:

                        RewriteCond %{HTTPS} off

                        First rewrite to HTTPS:

                        Don't put www. here. If it is already there it will be included, if not

                        the subsequent rule will catch it.

                        RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

                        Now, rewrite any request to the wrong domain to use www.

                        RewriteCond %{HTTP_HOST} !^www.
                        RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

                        Direct_Ram 1 Reply Last reply Reply Quote 4
                        • 1 / 1
                        • First post
                          Last post

                        Got a burning SEO question?

                        Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.


                        Start my free trial


                        Explore more categories

                        • Moz Tools

                          Chat with the community about the Moz tools.

                          Getting Started
                          Moz Pro
                          Moz Local
                          Moz Bar
                          API
                          What's New

                        • SEO Tactics

                          Discuss the SEO process with fellow marketers

                          Content Development
                          Competitive Research
                          Keyword Research
                          Link Building
                          On-Page Optimization
                          Technical SEO
                          Reporting & Analytics
                          Intermediate & Advanced SEO
                          Image & Video Optimization
                          International SEO
                          Local SEO

                        • Community

                          Discuss industry events, jobs, and news!

                          Moz Blog
                          Moz News
                          Industry News
                          Jobs and Opportunities
                          SEO Learn Center
                          Whiteboard Friday

                        • Digital Marketing

                          Chat about tactics outside of SEO

                          Affiliate Marketing
                          Branding
                          Conversion Rate Optimization
                          Web Design
                          Paid Search Marketing
                          Social Media

                        • Research & Trends

                          Dive into research and trends in the search industry.

                          SERP Trends
                          Search Behavior
                          Algorithm Updates
                          White Hat / Black Hat SEO
                          Other SEO Tools

                        • Support

                          Connect on product support and feature requests.

                          Product Support
                          Feature Requests
                          Participate in User Research

                        • See all categories

                        • Getting indexed in Google Scholar
                          SimpleSearch
                          SimpleSearch
                          1
                          4
                          612

                        • What do we know about the "Shops" SERP Feature?
                          seoelevated
                          seoelevated
                          0
                          1
                          3.1k

                        • Best proxy service to browse the Google from different countries to check the ranking
                          vtmoz
                          vtmoz
                          0
                          4
                          3.5k

                        • Search results vary in chrome vs other browsers even in Incognito mode: Google's stand?
                          vtmoz
                          vtmoz
                          1
                          3
                          2.9k

                        • URL Parameter for Limiting Results
                          dkeipper
                          dkeipper
                          0
                          3
                          1.2k

                        • Ways to fetch search analytics - historical search query data from Google Search Console
                          NortonSupportSEO
                          NortonSupportSEO
                          0
                          3
                          2.2k

                        • How create product category in Google Analytics?
                          Tormar
                          Tormar
                          0
                          2
                          7.2k

                        • Create original content or Copy from several sources?
                          moneymm22
                          moneymm22
                          0
                          7
                          2.4k

                        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

                        Looks like your connection to Moz was lost, please wait while we try to reconnect.