.htaccess - Redirect to HTTP non-www to HTTPS www htaccess -


i want redirect direction our site https protocol, redirects it's not working. want this:

  • http://www.site.co https://www.site.co
  • http://site.co https://www.site.co

this htaccess:

rewriteengine on rewritecond %{https} off rewriterule ^(.*)$ https://www.domain.com/$1 [l,r=301]   rewritecond %{http_host} !^www\. rewriterule ^(.*)$ https://www.domain.com/$1 [l,r=301] 

the second rule it's not working. going direction inside our site, , isn't redirect https site.

try this:

rewriteengine on  rewritecond %{http_host} !^www\. [nc] rewriterule ^(.*)$ http://www.domain.com/$1 [l,r=301]  rewritecond %{https} off rewriterule ^(.*)$ https://www.domain.com/$1 [l,r=301]  

the real difference here first redirect non-www www check https , redirect it.

if work try one:

rewriteengine on  rewritecond %{http_host} !^www\. [nc] rewriterule ^(.*)$ http://www.domain.com/$1 [l,r=301]  rewritecond %{server_port} !^443$ rewriterule ^(.*)$ https://www.domain.com/$1 [l,r=301]  

Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -