Reputation: 50
I have website which is i want to run on https://www.example.com
, i have set the rule on htaccess file and there i have written following rules.
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://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
After these rules, my website showing on google with www.example.com
and when i click on www.example.com
it redirect me www.www.example.com
means www are double time added in the url. I am looking if someone can help me on this part. thanks
Upvotes: 0
Views: 102
Reputation: 785581
You are getting double www
because of your 2nd rules where you are prefixing www.%{HTTP_HOST}
.
You can have your rules as:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
Make sure to use a new browser to test this change.
Upvotes: 1