I want to redirect my domain http to https and I have already do that with below mention code
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ https www.domain.com/$1 [L,R=301,NC]
When a user enter domain.com it’s automatically redirect to https www.domain.com But when user enter only www.domain.com it’s redirect to the http www.domain.com
Please help me to solve this issue.
2
Answers
You can use:
At your code :
It is a condition for the following rule ; so the rule will be applied only for none
www
request.Moreover , don’t use
R=301
redirection when you test new code unless you make sure that your rules is ok and you could useR=302
or justR
.regardless of your code Put the following code at your main directory
.htaccess
:If you want to force every request to be
www
you should do this :