No redirect or canonical to HTTPS homepage from HTTP version

I have a php site that I did an audit on via Semrush. I have this one error:

No redirect or canonical to HTTPS homepage from HTTP version

I added this just before my head closing tag:

<link rel="canonical" href=""/>

But that did not work, what am I doing wrong?

This is what my .htaccess file looks like

<IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ [L] RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_USER_AGENT} ^(.+)$ RewriteCond %{SERVER_NAME} ^mydomain\.health$ RewriteRule .* [R=301,L] Header add Strict-Transport-Security "max-age=300"
</IfModule>
1

1 Answer

Your canonical link should fix the problem. It would put a canonical tag into your document that should satisfy SEMRush. They have to recrawl your home page to see the tag, so it wouldn't surprise me if it took them days or weeks to note that the problem is resolved.

It looks like you are trying to redirect from HTTP to HTTPS but there are some problems with your .htaccess rules.

  1. Your front controller rule (the one with index.php) should come after the redirect rule. Any URL handled by your front controller would not redirect. (That is probably most of the URLs on your site.)

  2. I would not making the following exception: RewriteCond %{HTTP_USER_AGENT} ^(.+)$. All user agents should get the redirect to HTTPS.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like