.htaccess - Force all requests to use https:// and prepend www -
I have spent countless hours to solve this problem and it is doing my head. I'm sure this is very simple but I can not find any answer on StackVareflow dot com or other sites.
I am using an SSL certificate which is valid only for www.example.com and I am stuck with this certificate only for a number of reasons for the foolish corporate.
I want to apply all requests to SSL and apply www first to the domain, write the following domains properly:
example.com/ http://example.com/ http://www.example.com/ https://www.example.com/ The domain that is not written again and there is a problem, I reply anywhere Getting o
https://example.com It is only normal "certificate is not valid" skip warning.
I have the following code in the .htaccess file:
RewriteEngine% {HTTPS} on RewriteCond! = ^ ^ Rivat Raul. * $ Https: //% {SERVER_NAME}% {REQUEST_URI} [R, L] revaccount% {http_host} ^ example.com [nc] rewrote ^ ^. () * $ Https://www.example.com/$1 [ R = 301, L] I really hope that someone's solution is for me because I can not find the answer anywhere.
This should work:
RewriteEngine On RewriteCond% {HTTP_HOST }! ^ Www \. [NC] REERTUR ^^ (. *) $ Http: //www.% {HTTP_HOST} / $ 1 [L, R = 302] revaccount% {HTTPS} = revised rule ^ https: //% {HTTP_HOST}% {REQUEST_URI } [NC, R = 302, L] will check to see if there is www in the URL, if it does not, then add it Will give Check it and see if it is https and if it does not, it will add it.
Comments
Post a Comment