0

This is what I have done so far. In the settings in the admin I have updated the url to https e.g https://www.example.com

But if i was to visit a page for example https://www.example.com/contact-us and remove https://www. from the url it would not redirect to https://www.example.com/contact-us and instead serve up the non secure link. http://www.example.com/contact-us

So i have tried adding a rewriterule in the htaccess file for example this

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L,NE]

In the hope that it would capture any non-secure link and redirect it to the secure link (this is what i would normally use for non-wordpress sites)

I have also tried

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

This is a duplicated question but I have tried all the other examples but nothing has worked.

  • Have you cleared all caches and checked in a browser with the cache also cleared? If so, it's probably best to ask your host for assistance. Those rewrite rules look like they should do what you need but sometimes hosts have a specific configuration for https. You can also try one of the plugins that enforces SSL - sometimes those are easier to use than trying to solve server config or .htaccess issues. – WebElaine Apr 16 at 15:36
  • "and instead serve up the non secure link." - that's different to "getting redirected too many times" as stated in the title? So, which is it? And by "redirected too many times", do you mean a never ending "redirect loop", or a finite number of redirects? – MrWhite Apr 16 at 15:48
  • @mrwhite - I am receiving the redirected too many times message when i try the rewrite rules. – user165187 Apr 16 at 15:50
  • 1
    @webelaine - THanks I did some research into my host providers and turns out I needed to add something to the rewrite rule! – user165187 Apr 16 at 16:02
  • 1
    You should post what rewrite you added as the answer and than accept it so it helps others. – RiddleMeThis Apr 16 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.