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
-
Redirecting traffic to https
Hey! i was wondering, should i force all traffic to https address? i know that overall a better secured website will rank better since it earns more trust from users which means less bounce rate and the list of benefits is endless..
Intermediate & Advanced SEO | | SharonEKG
but should i FORCE ALL traffic to a https? or maybe only force a http to https? or not at all?2 -
Switching from HTTP to HTTPS: 301 redirect or keep both & rel canonical?
Hey Mozzers, I'll be moving several sites from HTTP to HTTPS in the coming weeks (same brand, multiple ccTLDs). We'll start on a low traffic site and test it for 2-4 weeks to see the impact before rolling out across all 8 sites. Ideally, I'd like to simply 301 redirect the HTTP version page to the HTTPS version of the page (to get that potential SEO rankings boost). However, I'm concerned about the potential drop in rankings, links and traffic. I'm thinking of alternative ways and so instead of the 301 redirect approach, I would keep both sites live and accessible, and then add rel canonical on the HTTPS pages to point towards HTTP so that Google keeps the current pages/ links/ indexed as they are today (in this case, HTTPS is more UX than for SEO). Has anyone tried the rel canonical approach, and if so, what were the results? Do you recommend it? Also, for those who have implemented HTTPS, how long did it take for Google to index those pages over the older HTTP pages?
Intermediate & Advanced SEO | | Steven_Macdonald0 -
Should I 301 this ecommerce site, or turn it into a blog?
Hey everyone, I have a couple of ecommerce sites - Site 1 (DA33) and Site 2 (DA24). They are in the same niche and have the same products, a relic of how our business started in 2007. But now we just want to manage one brand, Site 1. This is our question: Is it better to 301 Site 2 into Site 1 (page by page redirect), or would it be valuable to instead turn Site 2 into a blog site? Site 2 currently has some good relevant links to it that would be nice to 301 to Site 1, but the value of 301 redirects seems to have been steadily diminishing since roughly 2011. If we take Site 2 and turn it into a WordPress blog, develop some good industry-relevant content on it (and outsource/allow guest posts on it for relevant quality content as well), and sometimes we drop a link or two into the content to help promote Site 1 - would that be more valuable than a 301? Obviously, a lot more "work" goes into creating a content site than just 301'ing it over. I guess the question is: does a page-by-page 301 of a niche-identical and even product-identical site into another have more of a benefit for SEO than getting some content-relevant anchor text links on a blog site? What would you do in my position?
Intermediate & Advanced SEO | | mozUser14692350692210 -
How to properly implement HTTPS?
We are looking at implementing HTTPS for our site. I have done a little research but can't find anything recent, http://moz.com/community/q/duplicate-content-and-http-and-https is the most recent thing I found. Does everything in the answers still apply? Should I just do a 301 redirect to all new https? Or add a canonical tag?
Intermediate & Advanced SEO | | EcommerceSite0 -
Http, https and link juice
I'm working on a site that is built on DNN. For some reason the client has set all pages to convert to HTTPS (although this is not perfect as some don't when landing on them). All pages indexed in Google are straight HTTP, but when you click on the Google result a temp 302 header response to the corresponding HTTPS page for many. I want it changed to a 301 but unfortunately is an issue for DNN. Is there another way around this in IIS that won't break DNN as it seems to be a bit flaky? I want to have the homepage link juice pass through for all links made to non HTTPS homepage. Removing HTTPS does not seem to be an option for them.
Intermediate & Advanced SEO | | MickEdwards0 -
Www vs. non-www differences in crawl errors in Webmaster tools...
Hey All, I have been working on an eCommerce site for a while that to no avail, continues to make me want to hang myself. To make things worth the developers just do not understand SEO and it seems every change they make just messes up work we've already done. Job security I guess. Anywho,most recently we realized they had some major sitemap issues as almost 3000 pages were submitted by only 20 or so were indexed. Well, they updated the sitemap and although all the pages are properly indexing, I now have 5000+ "not found" crawl errors in the non-www version of WMT and almost none in the www version of the WMT account. Anyone have insight as to why this would be?
Intermediate & Advanced SEO | | RossFruin0 -
Experience with 307 HTTP status code
Hello, is there anybody how has got some experience with 307 HTTP status code? We would like to use 307 HTTP status code (temp redirect) for disabling temporary some of our shop-categories where all products are out of stock. Generally a few days or hours later products are back in stock and category page is also back. Is it a good idea to use 307 beccause link sould be disabled temorary or should we use 301 instead? Best regards Steffen
Intermediate & Advanced SEO | | steffen_0