The following code of .htaccess:

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

A problem occurs. A web browser usually displays the “too much requests”. This method doesn’t work anymore.

There is a way to fix this:

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

So the %{SERVER_PORT} returns 443 if you have connected to the site using https. This method can stop the “too much requests” problem.

This error has nothing to do with .htaccess , HTTP 429 is a sign of getting rate-limited by the server(Sending too many requests in a given amount of time).

refer = 429 Too Many Requests - HTTP | MDN


I would highly recommend to use this line instead in that case:

RewriteCond %{HTTPS} !=on

I personally really dislike the port check because you’re relying on something unimportant like a port number while it’s perfectly fine to do HTTPS on a completely different port. The HTTPS variable is there to tell you whether the connection is using HTTPS, which is the thing you specifically want to know.

I’ll make sure to update the article soon to have a .htaccess snippet which works on both parameters.


This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.