Fix 301 Redirect chains


I have an issue with my domain on the SEO audit report. There is a redirect chain on my main URL. redirecting to then its again redirecting to

How can I fix this? When I checked in .htaccess file I found this piece of code

# HTTPS forced by SG-Optimizer
<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteCond %{HTTP:X-Forwarded-Proto} !https
	RewriteCond %{HTTPS} off
	RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

There are several ways to do the redirection, but this is how I do it:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]
RewriteRule .?{REQUEST_URI} [R=301,L]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule .?{REQUEST_URI} [R=301,L]

Also, I would do away with the If and /If. The htaccess file is processed for every file that needs to be loaded so it can create quite an overhead. So long as you have the rewrite module installed the if statement’s not needed.

1 Like

Sure, I’ll remove the existing one and replace with the one you have provided.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.