14

I'm trying to redirect a single page from http to https using .htaccess, but I keep getting a redirect loop error.

Code:

Redirect /secureform.html https://www.example.com/secureform.html

However, I keep getting a "this webpage has too many redirects" error. How do I keep this from happening?

Liz Reeder
  • 155
  • 1
  • 1
  • 4

2 Answers2

20

Try this :

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^secureform\.html$ https://www.example.com/secureform.html [L,R=301]
Oussama Jilal
  • 7,669
  • 2
  • 30
  • 53
  • 1
    The rewriteRule can be written more generically, which might make it more portable by using `%{HTTP_HOST}` and `%{REQUEST_URI}` for example: `RewriteRule ^secureform\.html$ %{HTTP_HOST}%{REQUEST_URI} [L,R=301]` – Richard Greenwood Jun 20 '18 at 19:59
-3

I have tried this and it works for me:

Redirect permanent /secure https://www.example.com
TLama
  • 75,147
  • 17
  • 214
  • 392