.htaccess Rewrite code to 301 redirect my URL path to fix canonical issues

108 Views Asked by At

I discovered recently that a Hostgator tech inserted rewrite code in my .htaccess file which 302 redirected all of my pages to https://example.com even though I wasn't using that URL path for my sitemap or internal links. Now I have a mix of URL paths indexed by Google and lots of duplicate pages.

Trying to clean it up and use one URL path -> https://example.com

This is the code they inserted:

RewriteCond %{HTTP_HOST} example\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]
RewriteEngine on
RewriteOptions inherit

Can I simply change the [R,L] to [R=301,L] so that now everything will be a permanent redirect? I will also update all internal links and sitemap to use this URL path.

0

There are 0 best solutions below