Is it possible to direct HTTP www 301 to HTTPS non www?
-
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!
-
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] -
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
-
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] -
You should be able to change this in your .htaccess file.
RewriteEngineOn
RewriteCond%{SERVER_PORT}80
RewriteRule^(.*)$https://yourdomain.com/$1 [R=301,L]
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
After 301 redirect
hello i do after 301 redirect from old domain to new since 3 month ago my qa : should i replace the backlinks links to new doamin Or the he backlinks in the old link will works
Intermediate & Advanced SEO | | cristophare790 -
301 Redirect and Canonical link tag pointing in opposite directions!
I'm working on a site which redirects the non-WWW version to WWW version so, for example https://website.com/page redirects to https://www.website.com/page However, canonical link tags have been set up on the page - pointing back to the non-WWW so for example Q - is this going to cause issues and should the canonical be updated to the same version as the redirect?
Intermediate & Advanced SEO | | SWEMII0 -
301 redirect to search results page?
Hi - we just launched our redesigned website. On the previous site, we had multiple .html pages that contained links to supporting pdf documentation. On this new site, we no longer have those .html landing pages containing the links. The question came up, should we do a search on our site to gather a single link that contains all pdf links from the previous site, and set up a redirect? It's my understanding that you wouldn't want google to index a search results page on your website. Example: old site had the link http://www.oldsite.com/technical-documents.html new site, to see those same links would be like: http://www.newsite.com/resources/search?View+Results=&f[]=categories%3A196
Intermediate & Advanced SEO | | Jenny10 -
Our site is on a secure server (https) will a link to http:// be of less value?
Our site is hosted on a secure network (I.E. Our web address is - https://www.workbooks.com). Will a backlink pointing to: http://www.workbooks.com provide less value than a link pointing to: https://www.workbooks.com ? Many thanks, Sam
Intermediate & Advanced SEO | | Sam.at.Moz0 -
Problem with Google reading https homepage?
Hi Moz Community, In July, we changed our homepage to https via a 301 redirect from http (the only page on our site with https). Our homepage receives an A grade in the ‘On Page Grader’ by Moz for our desired keyword. We have increased our backlink efforts directly to our homepage since we switched to the SSL homepage. However, we still have not increased in search ranking for our specific keyword. Is there something we could have missed when doing the 301 redirect (submitting a new sitemap, changing rotbots.txt files, or anything else??) that has resulted in Google not correctly accessing the https version? (the https page has been indexed by Google). Any help would be greatly appreciated.
Intermediate & Advanced SEO | | G.Anderson0 -
Effects of having both http and https on my website
You are able to view our website as either http and https on all pages. For example: You can type "http://mywebsite.com/index.html" and the site will remain as http: as you navigate the site. You can also type "https://mywebsite.com/index.html" and the site will remain as https: as you navigate the site. My question is....if you can view the entire site using either http or https, is this being seen as duplicate content/pages? Does the same hold true with "www.mywebsite.com" and "mywebsite.com"? Thanks!
Intermediate & Advanced SEO | | rexjoec1 -
Disavow Tool - WWW or Not?
Hi All, Just a quick question ... A shady domain linking to my website is indexed in Google for both example.com and www.example.com. If I wan't to disavow the entire domain, do I need to submit both: domain:www.example.com domain:example.com or just: domain:example.com Cheers!
Intermediate & Advanced SEO | | Carlos-R0 -
What on-page/site optimization techniques can I utilize to improve this site (http://www.paradisus.com/)?
I use a Search Engine Spider Simulator to analyze the homepage and I think my client is using black hat tactics such as cloaking. Am I right? Any recommendations on to improve the top navigation under Resorts pull down. Each of the 6 resorts listed are all part of the Paradisus brand, but each resort has their own sub domain.
Intermediate & Advanced SEO | | Melia0