-2

i have SEO problem for http to https and non-www to https://www Please help me how to solve this problem?

this is my htaccess code:

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} somefolder
RewriteRule ^(.*)$ https://www.domain.com/somefolder/$1 [R,L]
# Ensure we are using HTTPS version of the site.
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://www\.%{HTTP_HOST}/$1 [R=301,L]
Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58

1 Answers1

0

For the latter rule, use:

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

So now it redirects from all non-www. hosts to https://www, because the destination URL is changed.

Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58