0

I want to redirect:

http://www -> httpS://www
http://    -> httpS://WWW
https://   -> https://WWW

In one redirect move 301, Like google!

Could you please help me to do that?

Follow .htaccess make redirect loop

RewriteEngine On

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.mydomain.com%{REQUEST_URI} [R=301,L,NE]

# Remove Trailing Slashes...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^(.+?)/$ /$1 [R=301,L,NE]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Update 1

And with follow htaccess, I receive 302 Not found for https://www

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI}$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}$1

I have two cname record, once for www.mydomain.com and another for mydomain.com

Daniyal
  • 119
  • 3
  • 8
  • possible duplicate of [Redirect all http AND https non-www URLS to https://www.xyz.com via htaccess](http://stackoverflow.com/questions/17638611/redirect-all-http-and-https-non-www-urls-to-https-www-xyz-com-via-htaccess) – Regular Jo Dec 04 '14 at 06:56
  • Open your page in Firebug or Chrome dev tool. Check in Net tab what redirects you see there. – anubhava Dec 04 '14 at 07:06
  • @cfqueryparam Thanks I check it, but I receive 302 not found for `https://www` – Daniyal Dec 04 '14 at 07:14
  • Do you get 302 for `https://www.domain.com` also? – anubhava Dec 04 '14 at 07:18
  • @anubhava for first code yes, for second code no just get 302. Thanks for your attention – Daniyal Dec 04 '14 at 07:20
  • Didn't get your comment. Are you getting any 302/301 when you open `https://www.domain.com` using 1st code and then 2nd code? – anubhava Dec 04 '14 at 07:22

0 Answers0