Optimize your 301 redirects for SEO
If you host a WordPress site and use the Really Simple SSL plugin for SSL detection and configuration, you may have a less than optimal setup for SEO purposes.
Really Simple SSL default setup
The .htaccess redirect method is not enabled by default since it can cause problems with some configurations but is recommended when possible since it’s generally a faster redirect than using Javascript or the WordPress 301 redirect. Once enabled, the plugin recommends the following .htaccess changes to redirect HTTP requests to HTTPS for your domain:
This gets you a lot of the way there because it ensures that anyone who visits your site will always do so using a secure HTTPS connection. It does, however, introduce two potential SEO-impacting issues.
Problem: Multiple 301 redirects
The specified rules cause a 301 redirect chain. Having too many redirects reduces page speed and authority. 1:1 redirects are preferred, but you end up with two hops per request given the provided rules. You can test this for your own domain using httpstatus.
Problem: Duplicate (non-canonical) URLs
Search engines like Google see www and non-www URLs as separate URLs pointing to duplicate content. In other words, https://www.aurorafoundry.com/blog/ and https://aurorafoundry.com/blog/ get crawled as two different pages, containing the same content.
I guess this is because Google refuses to acknowledge the age-old standard that www is not like other subdomains ¯\_(ツ)_/¯. But in any case, by not having a canonical URL for any given piece of content, you’re leaving it up to the search engines to decide. Google tries to infer this automatically, but you can end up with link juice split between different versions of the exact same content. You’ll also see a lot of extra noise in the search console and in many SEO analysis tools if you don’t address this with proper server-side redirects for your www URLs.
Solution: Better .htaccess rewrite rules
By modifying your .htaccess with the following rewrite rules, you’ll redirect the entire domain from non-www to www and HTTP to HTTPS, with only a single 301. This will also clear up canonical issues with www vs non-www URLs.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
0 Comments