0

I am trying to redirect my domain

and

to

My hosting company gave me this code for the .htaccess file:

Options +FollowSymlinks 
RewriteEngine on 
RewriteCond %{HTTPS_HOST} ^atc-logistics.ie [NC] 
RewriteRule ^(.*)$ https://www.atc-logistics.ie/$1 [L,R=301]

and are insisting that there this is correct and something else is causing a redirect so it keeps rebounding back to http://atc-logistics.ie. I can't see any other redirects and there are no redirect plugins (Wordpress).

Can anyone let me know if the redirect above is correct? I am really struggling and the hosting company don't seem to be able to help!

Amit Verma
  • 40,709
  • 21
  • 93
  • 115
orlafitz
  • 101
  • 1
  • 10
  • please read [this StackOverflow answer](http://stackoverflow.com/a/13997498/3536236) – Martin May 17 '16 at 14:20
  • And / or read up on [this StackOverflow topic](http://stackoverflow.com/questions/4398951/force-ssl-https-using-htaccess-and-mod-rewrite) – Martin May 17 '16 at 14:43
  • Thanks Martin, neither seemed to work, I just don't have the skills to troubleshoot them. Looks like I might just have to keep bugging the hosting company. I need to take a break from it - have been staring at .htaccess files for 4 hours - I might spontaneously combust. – orlafitz May 17 '16 at 14:54

1 Answers1

0

The htaccess redirect system I use is this:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

And that works fine for me.

It checks if the host does not begin www. and then diverts to the www. address before then checking if the protocol is Secure and then if it is not forces redirect to the HTTPS, using the previously set HOST and URI address values.

Martin
  • 22,212
  • 11
  • 70
  • 132