Home > Back-end >  .htaccess: How to define Rewrite Rule depending on HTTP status code
.htaccess: How to define Rewrite Rule depending on HTTP status code

Time:03-04

I want to define a .htaccess rewrite condition that allows me to define a rewrite rule depending on HTTP status code. With PHP there is no problem, but in .htaccess I found no solution in any Apache documentation.

CodePudding user response:

It's about status codes 30x, 4x and 50x and if they are set by any application.

That's simply not possible with .htaccess.

By the time the application is sending back the response, mod_rewrite (RewriteRule / "rewrite condition") has long since finished processing the request.

You can only check the HTTP request, not the response with mod_rewrite.

  • Related