Redirect chains from switch to HTTPS
-
Hi,
We have a client who recently switched their site to https://
The rule to force redirect non-secure URLs to https is in their .htaccess file:
RewriteEngine on
if non-SSL and one of these, redirect to SSL
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://www.clientdomain.com/$1 [R=301,L]However, they also have simple redirects below this rule that redirect one page to another, such as:
Redirect 301 /old.php https://www.clientdomain.com/new.php
This is causing redirect chains like this:
(A) http://www.clientdomain.com/old.php > (B) https://www.clientdomain.com/old.php > (C) https://www.clientdomain.com/new.php
Is there any way to rewrite the rules in .htaccess to get rid of these redirect chains? So that URL A goes directly to URL C?
Thank you!
-
Hi,
We are still waiting for the developer to make the change. I will certainly post the answer when we know for sure!
Thanks
-
Hi was this ever resolved as this would help many people?
-
Thank you!! Just sent it
-
Yes - of course. Happy to take a look.
-
Hi Will,
That is correct - the developer told me that's exactly what he did. Could I send you a screenshot of the actual .htaccess file in a private message?
Thank you!
-
Hi Lori,
On closer inspection, I think that only the rewriterule should have the [L] flag and that placing the specific Redirect at the top of the file should work fine without chained redirects as the other commenters suggested. I tested that here: http://htaccess.mwl.be/ and it appears to work fine using the following .htaccess - can you confirm with your developer that this is what they were trying?:
Redirect 301 /old.php https://www.clientdomain.com/new.php
RewriteEngine on
if non-SSL and one of these, redirect to SSL
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://www.clientdomain.com/$1 [R=301,L] -
Thank you Will! Just one question, so if it's a simple redirect from one page to another, it would look like this? Or is adding [R=301,L] only for those that start with RewriteRule?
Redirect 301 /Bamboo https://www.fauxpanels.com/style-wood.php [R=301,L]
-
Hi Lori. The solution the other commenters have suggested is definitely the way to do this - so it sounds like it needs more debugging. I suspect it's to do with the [L] option being needed on the specific redirect once it's moved above the general http-->https redirect. This stops other redirects below it firing, if I remember correctly.
If that doesn't work, do you want to share back here the specific different htaccess files the developer has tried?
-
So the developer got back to me and said he had tried that but the redirect chain still occurred. Any other ideas?
-
So the developer got back to me and said he had tried that but the redirect chain still occurred. Any other ideas?
-
The easy solution (and recommended best practice) is to put the specific individual redirects above the HTTPS redirect in the htaccess file. Just make certain the legacy individual redirects point to the correct HTTPS version to start with.
It's standard procedure to have an htaccess file list the most specifically targeted rules first, gradually moving to the more general.
Hope that helps?
Paul
-
Thank you! Will try and let you know
-
I guess you could probably do this by checking the https rule at last. So if it is old.php, the first thing you do is redirect to the new.php but already on the https. So all your static redirects will automatically go to https with one redirect while the other will always reach the last rule and go to the secure versions. Let me know if this helps.
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
-
301 Redirect and Loss of PA and DA
Mozzers, http:itsgr82bme.com Old domain homepage had a DA of 24 and a PA of 36 Currently redirected to http://thekidstime.com Homepage shows a DA of 6 and a PA of 1. That is a significant loss of authority. I thought a 301 is supposed to be better than that. What gives? What are the next steps, asking the old backlinks to update their links? Thanks for your help, Matt
Intermediate & Advanced SEO | | matt.nails0 -
Should I redirect my HTTP to my HTTPS ?
I am about to make a domain name change for my online shop. I have heard that redirecting my HTTP to my https is a good SEO Practice. I have www, non-www, as well as https-www and https-non-www declared in Search console. Both have non-www set as preferred domain. Is the redirect rule from HTTP to https really usefull ? Thanks
Intermediate & Advanced SEO | | Kepass0 -
Blog subdomain not redirecting
Over the last few weeks I have been focused on fixing high and medium priority issues, as reported by the Moz crawler, after a recent transition to WordPress. I've made great progress, getting the high priority issues down from several hundred (various reasons, but many duplicates for things like non-www and www versions) to just five last week. And then there's this weeks report. For reasons I can't fathom, I am suddenly getting hundreds of duplicate content pages of the form http://blog.<domain>.com</domain> (being duplicates with the http://www.<domain>.com</domain> versions). I'm really unclear on why these suddenly appeared. I host my own WordPress site ie WordPress.org stuff. In Options / General everything refers to http://www.<domain>.com</domain> and has done for a number of weeks. I have no idea why the blog versions of the pages have suddenly appeared. FWIW, the non-www version of my pages still redirect to the www version, as I would expect. I'm obviously pretty concerned by this so any pointers greatly appreciated. Thanks. Mark
Intermediate & Advanced SEO | | MarkWill0 -
Http to https question (SSL)
Hi, I recently made two big changes to a site - www.aerlawgroup.com (not smart, I know). First, I changed from Weebly to Wordpress (WP Engine hosting with CDN + Cloudflare - is that overkill?) and I added SSL (http to https). From a technical perspective, I think I made a better site: (1) blazing fast, (2) mobile responsive, (3) more secure. I'm seeing the rankings fluctuate quite a bit, especially on the important keywords. I added SSL to my other sites, and saw no rankings change (they actually all went up slightly). I'm wondering if anyone has had experience going to SSL and can give me feedback on something I might have overlooked. Again, it's strange that all the other sites responded positively, but the one listed above is going in the opposite direction. Maybe there are other problems, and the SSL is just a coincidence. Any feedback would be appreciated. I followed this guide: http://moz.com/blog/seo-tips-https-ssl - which helped tremendously (FYI).
Intermediate & Advanced SEO | | mrodriguez14400 -
SEO for a redirected domain name
Our client is a law firm with a name that is challenging to spell. We have procured a domain name for them that is catchy, easy to spell, and plays well into their brand, or at least the current campaign. We're using the campaign domain to direct traffic to their website with a 301 redirect. We have placed the campaign domain in a variety of offline mediums including print and outdoor. The client is currently in the number 1 spot for a good number of our highest priority keywords, so I do not want to do anything to jeopardize that. I'm also not sure this campaign will be their "brand" long-term so I don't want to risk making a switch and making it back. So for now, I'm most comfortable leaving the campaign domain as a redirect to their primary domain. Recently, the client approached me complaining (legitimately) that when people google the campaign domain, they are brought to search results for an entirely different domain because Google "corrects" the domain name for them. This is obviously a bad thing, with many users defaulting to entering urls into Google instead of the address bar. If you tell Google that it was wrong about the autocorrection, our site is in the number 1 position. I liken the situation to Overstock.com using O.co as their offline domain, but overstock.com as their online domain. But imagine if you googled o.co and google brought you to a list of results for "on.co" because it assumed you fat-fingered it. Is there anything I can do to prevent the domain name from getting corrected by Google?
Intermediate & Advanced SEO | | steverobinson0 -
Redirect 301
Hi, I `m redirecting some pages in htaccess The first 15 pages that i redirected it worked. But the last 3 dont work, and i cant figure it out why it is not working. Redirect 301 /analyseverktoy/ /webanalyse
Intermediate & Advanced SEO | | SGacic
Redirect 301 /index.php/ledige-stillinger/ /
Redirect 301 /?page_id=352/ / Anu suggestions?0 -
307 Redirect
Just checking the headers on a client site and discovered a 307 redirect. General suggestion from http status code sites is that it is similar to a 302 temporary redirect. Can someone confirm this is the case or is there a difference?
Intermediate & Advanced SEO | | bjalc20110 -
Redirect or Rewrite? 2 pages ranking
We have two pages ranking for "Custom Web Design" http://www.imageworksstudio.com/custom-web-design ranks higher (consistently 9-13) and http://www.imageworksstudio.com/content/custom-web-design ranks around 35-40 the latter is actually an older version of the article that never was replaced or taken down - but it has the majority of the links to it Wondering if we should update the old content so it is not similar to the one that is ranking better or if we should redirect everything to /custom-web-design to see if it can secure better rankings?
Intermediate & Advanced SEO | | imageworks-2612900