Redirect Coding Help

Need some guidance with CODE:

Google (the evil one) search console reports 48 redirect errors on my site. The pages consist of http://customdrains.com/+path to pages or https://www.customdrains.com/+path to pages

As far as I know the “Domain” resolves to the https://

Here is what I have in the .htacess file currently (which is way above my technical pay grade):

RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.customdrains\.com [NC] RewriteRule ^(.*)$ http://customdrains.com/$1 [L,R=301]

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://customdrains.com/$1 [R=301,L]

DirectoryIndex index.php index.html
ErrorDocument 404 /404/

I’d like to get all the pages to redirect to corresponding page in the https:// mode to make these errors go away.

Thanx in advance for your help, I truly appreciate it.

Pearson


Hey @pearson4,

Try removing:

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^www\.customdrains\.com [NC] 
RewriteRule ^(.*)$ http://customdrains.com/$1 [L,R=301]

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://customdrains.com/$1 [R=301,L]

And replacing it with:

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.customdrains\.com [NC]
RewriteRule ^(.*)$ https://customdrains.com/$1 [L,R=301]

Let us know if you get any errors after doing that.

1 Like