-1

I want to redirect https://example.com to https://www.example.com for my website. Can you help me with the code to put it on .htaccess file. the site is in magento.

  • 3
    Possible duplicate of [Need help understanding .htaccess](http://serverfault.com/questions/107460/need-help-understanding-htaccess) – Sam Cogan Mar 31 '16 at 13:58

1 Answers1

1

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www.

RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

There you go

Root
  • 19
  • 2
  • thanks for the quick response, but it isn't working, i want from HTTPS non-www to HTTPS . both are in https, i have non-www http -> https www and HTTP with www to -> HTTPS WWW but i need NON-WWW HTTPS TO WWW-HTTPS . – Hari krishna Mar 31 '16 at 14:17
  • You should add one additional condition - ```RewriteCond %{HTTPS} =on``` or ```RewriteCond %{SERVER_PORT} ^443$``` – ALex_hha Mar 31 '16 at 14:49
  • it doesnt work as well, i need HTTPS://example.co.uk to HTTPs://WWW.example.co.uk it is in magento, the .htaccess file just has order deny,allow deny from all written in it. i have place the code below it. – Hari krishna Mar 31 '16 at 15:32