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. Alternative Search Sources
    4. 302 redirect on http but not on https

    302 redirect on http but not on https

    Alternative Search Sources
    11 4 10.3k
    • 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.
    • 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
      • 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
        • 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
          • Direct_Ram
            Direct_Ram last edited by

            This post is deleted!
            BlueprintMarketing 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
              • BlueprintMarketing
                BlueprintMarketing @Direct_Ram 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 @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
                  • 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
                    • 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
                      • 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
                        • 1 / 1
                        • First post
                          Last post
                        • Please help me? DA of my website decreased last 1 month what could be the reason?
                          BartonInteractive
                          BartonInteractive
                          0
                          7
                          62

                        • Has anyone used youramigo or know what Technics they use or alternative to YourAmigo
                          0
                          1
                          53

                        • Sponsor in flight ticket section
                          faikanuril0123
                          faikanuril0123
                          0
                          9
                          150

                        • App Store Optimization
                          1
                          1
                          98

                        • Is it bad for international SEO to redirect CcTLDs and install Google website translator plugin to the primary domain (UK)?
                          robmarsden
                          robmarsden
                          0
                          2
                          349

                        • Upcity.com
                          brightvessel
                          brightvessel
                          0
                          4
                          864

                        • How to count number of app's installations for users who install app from https://play.google.com?
                          willcritchlow
                          willcritchlow
                          0
                          2
                          3.1k

                        • Redirection of domain maybe affected by google
                          TommyTan
                          TommyTan
                          0
                          2
                          204

                        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