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,567
  • 1
  • 26
  • 53
  • 1
    @LizReeder Welcome to SO. If this answer solved your problem, consider [accepting](http://meta.stackexchange.com/a/5235) it. – Olaf Dietsche Apr 22 '13 at 20:37
  • 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
  • 73,451
  • 17
  • 201
  • 368