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
-
Unintentional wildcard 301 Redirect?
I have migrated a client's site to a new domain. I used Yoast tools to add 301 redirects for all active site pages from old domain to new domain in the .htacces files as neither the client nor I have access to hosting server via FTP (long story). Redirects are working as I intended, and we didn't lose too much in our rankings. Unfortunately, as soon as I saved the .htaccess file in Yoast, old-domain.net/wp-admin began redirecting to new-domain.net/wp-admin. I can no longer login to the wordpress site on the old domain. I did not enter a redirect for /wp-admin. Any thoughts on how this is happening or if there is some other way to get back in? Without server access, I'm pretty stumped. Thanks!
Intermediate & Advanced SEO | | c_estep_tcbguy0 -
Http to https what should one look out for
Hi, we are moving our site from http to https and would like to know what should one look out for. What are the things that can go wrong, and what is the best way to go about it. Regards Tai
Intermediate & Advanced SEO | | Taiger0 -
LinkedIn 999 HTTP Errors
I am working on a website, https://linkedinforbusiness.net and a ton of 999 HTTP errors have only now surfaced. I would venture from reading the "Request denied" error in the log, LinkedIn means to block BLCs attempts to check those links. It might be because the site has a lot of LinkedIn links; maybe they find it suspicious that the server is sending a lot of requests for their links. How do you see this? Any fixes? What level of harm do you think it brings to the site? I have removed all similar links to LinkedIn from my site to avoid this (https://www.hillwebcreations.com). However, this isn't so easily done for LinkedIn For Business, as her work in all about helping businesses and individuals optimize their use of LinkedIn.
Intermediate & Advanced SEO | | jessential0 -
Is it possible to predict the future DA of a site?
Is there a method to predict the future DA of a site if I know the DA and PA of x sites that will be linking to them in the future? All inbound links will be pointing to the home page.
Intermediate & Advanced SEO | | richdan0 -
Website losing rank positions after https
Hi there.. we were having a good increase in rankings since using Moz and then we purchased an ssl certificate so our website would run under https... to make sure our website is only accessed through https, we have used a method on .htaccess (appache) to make sure the website is only reached through https, using: RewriteEngine on
Intermediate & Advanced SEO | | mszeer
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,QSA] after doing this, from our last crawl perspective, we lost several positions that we were increasing.. what have we done wrong ? we have to fix this asap, please help us...0 -
Why do my https pages index while noindexed?
I have some tag pages on one of my sites that I meta noindexed. This worked for the http version, which they are canonical'd to but now the https:// version is indexing. The https version is both noindexed and has a canonical to the http version, but they still show up! I even have wordpress set up to redirect all https: to http! For some reason these pages are STILL showing in the SERPS though. Any experience or advice would be greatly appreciated. Example page: https://www.michaelpadway.com/tag/insurance-coverage/ Thanks all!
Intermediate & Advanced SEO | | MarloSchneider0 -
Should you replace the url on a damaged page and 301 to it ?
Hi, We have a couple of pages which have been damaged due to an SEO person we hired creating a stupid amount of bookmarks and generally poor links. I've tried to get the links removed where I can but on most of these blogging sites there is no contact webmaster etc so I am struggling. Panda update as also affected traffic by about 35%. My question is , should I consider creating new urls for the "damaged " pages and then doing 301 redirects to them from the damaged page to the new page. Then start to build up good links to the new page whilst google should de-index the old pages over a couple of months ?. Just at my witts end how to get rid of these blogging rubbish etc etc. Thanks Sarah.
Intermediate & Advanced SEO | | SarahCollins0 -
Duplicate Content http://www.website.com and http://website.com
I'm getting duplicate content warnings for my site because the same pages are getting crawled twice? Once with http://www.website.com and once with http://website.com. I'm assuming this is a .htaccess problem so I'll post what mine looks like. I think installing WordPress in the root domain changed some of the settings I had before. My main site is primarily in HTML with a blog at http://www.website.com/blog/post-name BEGIN WordPress <ifmodule mod_rewrite.c="">RewriteEngine On
Intermediate & Advanced SEO | | thirdseo
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]</ifmodule> END WordPress0