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. Is it possible to direct HTTP www 301 to HTTPS non www?

    Is it possible to direct HTTP www 301 to HTTPS non www?

    Intermediate & Advanced SEO
    5 3 656
    • 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.
    • Stodzy
      Stodzy last edited by

      I have a question that has been stumping me and if someone could help I would gladly buy your coffee for a month.

      I have a website that used to be www and http a year or two ago.  Now it is https and non www.  A lot of my older links point to the www and http version of my site.  This results in two 301 redirects.

      I.e.

      A link on another site to my site points to http://www.mysite.com

      The network waterfall shows:

      http://www.mysite.com  301 -> http://mysite.com

      http://mysite.com 301 -> https://mysite.com

      https://mysite.com (finally)

      **2 part question.  **

      **--Do you think that this two 301 redirect hop would affect SEO performance?  I can see it did affect page authority through Moz. **

      --Is there away around this?  I.e. to redirect http:// AND http://www directly to https:// with no hops in between.

      Thank you!

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

        You should be able to change this in your .htaccess file.

        RewriteEngineOn

        RewriteCond%{SERVER_PORT}80

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

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

          Hello,

          I have not heard of this kind of setup affecting SEO performance, but I could be wrong. Even if you didn't have the old URL structure and incoming links, I would still have these redirects to ensure all the current site links are only accessible via one type of URL, https, non-www.

          These are the two redirects I have used in my .htaccess file to achieve what you are looking for. In the network I only see as one redirect listed though, not two. Hope this helps.

          RewriteCond %{HTTPS} !^on$
          RewriteRule (.*) https://example.com/$1 [R=301,L]

          RewriteCond %{HTTP_HOST} ^www.example.com [NC]
          RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

          Stodzy 1 Reply Last reply Reply Quote 1
          • Stodzy
            Stodzy @Whebb last edited by

            Thank you so much for your quick answer. I made it my mission to become a DNS, htaccess  and redirect expert over the next two weeks as it has been my Achilles heel for far too long. How would you write this with an htaccess file hosted in a on a server that's running Wordpress (WP Engine specifically)?

            This is the default WP htaccess file:

            # BEGIN WordPress
            
             <ifmodule mod_rewrite.c="">RewriteEngine On
            
            RewriteBase /
            
            RewriteRule ^index\.php$ - [L]
            
            RewriteCond %{REQUEST_FILENAME} !-f
            
            RewriteCond %{REQUEST_FILENAME} !-d
            
            RewriteRule . /index.php [L]</ifmodule> 
            # END WordPress
            
            1 Reply Last reply Reply Quote 0
            • Whebb
              Whebb last edited by

              Hello,

              With Wordpress I believe you can just add it under all that code, like below. After you make the changes, I would suggest opening a private browser window or clearing your cache and make sure the site, pages and redirects are coming up as intended, since .htaccess changes can sometimes be a bit hairy and cause the site to white screen or cause infinite loops.

              BEGIN WordPress

              RewriteEngine On
              RewriteBase /
              RewriteRule ^index.php$ - [L]
              RewriteCond %{REQUEST_FILENAME} !-f
              RewriteCond %{REQUEST_FILENAME} !-d
              RewriteRule . /index.php [L]

              END WordPress

              RewriteEngine On

              RewriteCond %{HTTPS} !^on$
              RewriteRule (.*) https://example.com/$1 [R=301,L]

              RewriteCond %{HTTP_HOST} ^www.example.com [NC]
              RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              • We are redirecting http and non www versions of our website. Should all versions http (non www version and www version) and https (non www version) should just have 1 redirect to the https www version?
                BlueprintMarketing
                BlueprintMarketing
                0
                8
                437

              • CNAME record for WWW to Non-WWW Vs. 301?
                0
                2
                430

              • Our client's web property recently switched over to secure pages (https) however there non secure pages (http) are still being indexed in Google. Should we request in GWMT to have the non secure pages deindexed?
                N1ghteyes
                N1ghteyes
                0
                3
                128

              • URL Redirect: http://www.example.net/ vs. http://www.example.net
                dotfly
                dotfly
                0
                2
                705

              • If your site has used www for the last few years is it a good idea to direct to non www?
                webestate
                webestate
                0
                7
                572

              • Is a 301 Direct with a canonical tag Possible ?
                AZWebWorks
                AZWebWorks
                0
                2
                283

              • Open Site Explorer not Seeing 301 Redirect to non-www
                KeriMorgret
                KeriMorgret
                0
                2
                744

              • Is it possible to 301 re-direct an entire subfolder on a subdomain?
                EricaMcGillivray
                EricaMcGillivray
                0
                2
                748

              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