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
-
New Domain, No 301 Possible - Any Advice
A client of mine lost their domain when an ex business partner sold it out from under them. They've filed with WIPO, but in the meantime we're trying to figure out how to help them out. They had two really excellent links - one from the NY Times and one from a .edu website. I'm going to reach out to the authors of those articles (the articles are pretty old, so I doubt they'll change the links), but does anyone have any advice on how to let search engines know the new domain replaces the old without having the ability to do redirects? The content on the site is exactly the same - we were able to get the files over, happily. I've re-submitted the site for indexing, changed the domain links in Moz Local, changed in Analytics, and on all their social sites. Is there anything I'm not thinking of that can be done to let Google know that this new domain replaces the old? Thank you!
Intermediate & Advanced SEO | | newwhy0 -
410 or 301 after URL update?
Hi there, A site i'm working on atm has a thousand "not found" errors on google console (of course, I'm sure there are thousands more it's not showing us!). The issue is a lot of them seem to come from a URL change. Damage has been done, the URLs have been changed and I can't stop that... but as you can imagine, i'm keen to fix as many as humanly possible. I don't want to go mad with 301s - but for external links in, this seems like the best solution? On the other hand, Google is reading internal links that simply aren't there anymore. Is it better to hunt down the new page and 301-it anyway? OR should I 410 and grit my teeth while google crawls and recrawls it, warning me that this page really doesn't exist? Essentially I guess I'm asking, how many 301s are too many and will affect our DA? And what's the best solution for dealing with mass 404 errors - many of which aren't attached or linked to from any other pages anymore? Thanks for any insights 🙂
Intermediate & Advanced SEO | | Fubra0 -
Moving content to a newer domain - 301 re-direct not possible
I had a website that was getting decent traffic. Around 2k visits a day. Owing to some issues, the domain was suspended my the domain provider and they won't be releasing it anytime soon. Now, I'm in talks with my domain provider and it might take some good time to get back the domain live (weeks if not months). So, I have decided to migrate all my content to a new domain. Also, Google has stopped displaying my earlier domain (the suspended domain) in the search results now and I have removed the property from webmaster tools/search console. And since my earlier domain is suspended, redirection is not possible. So, I had a couple query in regards to this: I'm in the process of moving the content from the older suspended domain to the newer domain. What should I do that Google does not penalise my new site on the grounds of duplicate content, etc. What other things I should do while I'm in the process of this migration.
Intermediate & Advanced SEO | | Evaway0 -
Fetch As Google Redirect from HTTPS to HTTP
Hi Moz Community, We just launched a redesigned site and moved our blog from http://sparkline.motifinvesting.com to https://www.motifinvesting.com/blog. When I went to check the site today I noticed something strange. When I Fetch a Blog URL as Google it is redirecting from https to http AND dropping the / <post-id>from the end of the URL.</post-id> So for the URL https://www.motifinvesting.com/blog/cleantech-obama-romney/1494 I am getting the attached results when I Fetch as Google. When I access the same URL in my browser, I see a 200 status code and no redirect. Why would Google Bot show that the URL is being redirected? Thanks,
Intermediate & Advanced SEO | | motif_marketing
Breanna https://www.motifinvesting.com/blog/cleantech-obama-romney/1494 I7yQPza.png0 -
301 redirect to a temporary URL
Hi there, What would happen if I redirected a set of URLs to a temporary URL structure. And then a few weeks later redirected the original URLs and temporary URLs to the final permanent URLs? So for example:A -> B for a few weeks.
Intermediate & Advanced SEO | | sichristie
then: A->C and B->C where:
C is the final destination URL.
B is the temporary destination
A is the original URL. The reason we are doing this is the naming of the URLs and pages are different, and we wish to transition our customers carefully from old to new. I am looking for a pure technical response.
Would we lose link juice? Does Google care if we permanently redirect to a set of 'temporary' URLs, and then permanently redirect to a set of what we think are permanent URLs? Cheers, Simon0 -
Any good link buying companies ( http://www.text-link-ads.com )
Hi guys I have been passed this website: http://www.text-link-ads.com Has anyone ever used text-links ads before?? Can anyone please show me the way and suggest any really good lin buying companies? I am really fiding it hard to find good places to place inbound links into our website.. Thanks Gareth
Intermediate & Advanced SEO | | GAZ090 -
Remove www. in google webmaster
Hi. My baseball blog (mopupduty.com) shows up as www.mopupduty.com in Google Webmaster tools. This is an issue for me, as my Wordpress plug-in sitemap will only show up on http://mopupduty.com/sitemap.xml , not the www. version Is there any way in changing the www. in webmaster tools without deleting my existing index. The website currently has sitelinks in search results, and I'm not too keen in giving them up via deletion. Thanks
Intermediate & Advanced SEO | | mkoster0 -
Meta HTTP-EQUIV
Hi people! When you try to access http://www.ufam.edu.br you are redirected to http://portal.ufam.edu.br. Here's the code: <title>UFAM - Universidade Federal do Amazonas</title> What are the implications for SEO of this ? Won't the juice be passed? Isn't it better for passing juice using redirect 301?
Intermediate & Advanced SEO | | marcelocustodio0