0

I am using .htaccess. I am trying to redirect http://www.example.co.uk AND http://example.co.uk to the secure https. I have searched on this site and tried all the suggestions, but none work. I have approached my hosting company and they have tried with no joy.

One example I used is -

RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^example\.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.co.uk$
RewriteRule ^(.*)$ https://www.example.co.uk/$1 [R,L]

Another example code I use is -

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://zapstudio.co.uk%{REQUEST_URI} [L,NE,R=301]

The error comes up as follows on Firefox:

The page isn’t redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete. This problem can sometimes be caused by disabling or refusing to accept cookies.

There is no other coding in my .htaccess file than the code inserted. Please, can anyone shed any light on this.

MrWhite
  • 43,179
  • 8
  • 60
  • 84
Zaptabby
  • 1
  • 1
  • Possible duplicate of [.htaccess Redirect Error](http://stackoverflow.com/questions/43803286/htaccess-redirect-error) – MrWhite May 05 '17 at 14:09
  • Thanks. I have gone through all that need help on this issue, but it has not solved my problem – Zaptabby May 05 '17 at 15:57
  • How is the SSL managed? See also this question: http://stackoverflow.com/questions/43743283/htaccess-rewrite-too-many-redirects – MrWhite May 05 '17 at 16:01
  • Many thanks for the reply. I have no idea how the SSL is managed. I am not a coding man, and I don't understand all the technicalities. All I have done is used just about all the snippets of coding people have kindly posted, and non seem to work. – Zaptabby May 05 '17 at 16:15
  • Please add the code you have tried to your question, you will probably need to include your entire `.htaccess` file since the order matters and you can get conflicts with other directives. – MrWhite May 05 '17 at 17:15
  • I have so many code snippets I have lost count, but I this this is the last one I used - – Zaptabby May 05 '17 at 17:25
  • RewriteEngine On RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} ^www\. [NC] RewriteRule ^ https://example.com%{REQUEST_URI} [L,NE,R=301] – Zaptabby May 05 '17 at 17:25
  • Clear your browser cache. If you have nothing in your htaccess then it's a caching issue. Don't test with 301, use 302 until you know your rules work how you want them. – Panama Jack May 05 '17 at 20:51
  • What about the contents of your `.htaccess` file? Or is that your entire file? – MrWhite May 05 '17 at 20:52
  • My hosting company has fixed it. All is working great now. They said it was something to do with cache. I did empty my browser cache but it was still doing it. My host said cache is on many levels, can't understand what they were on about. Anyway, thanks for your help w3dk and Panama Jack. – Zaptabby May 06 '17 at 08:12
  • @Zaptabby Thanks for the feedback. You can add that as an answer (and later accept it) - this removes the question from the unanswered question queue. However, although caches are indeed on "many levels", it's unusual that the problem would be a server-side caching issue that your host would be able to resolve? – MrWhite May 06 '17 at 11:26
  • That's what they said, I have no idea what they did, but its working :-) – Zaptabby May 06 '17 at 13:03
  • Are you suggesting it was something else they did? – Zaptabby May 06 '17 at 13:06

0 Answers0