I’d like to know why the following htaccess file produces a 500 error:
<IfModule !mod_rewrite.c>
ErrorDocument 500 "Your_Server_Is_Not_Compatible: Apache does not have mod_rewrite loaded. Please check your Apache setup."
RedirectMatch 302 .* index.php
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ versions/0/1/$1
</IfModule>
Thanks thanks in advance
You get a 500 error because you’re causing the server to enter an infinite loop (which it gets angry about, and throws an error to stop).
This is because of your
RewriteRule, which will always match:^(.*)$matches the valueversions/0/1/, so after you perform the initial rewrite, the rule set is re-evaluated and creates a cycle that looks like this:..and so on.
You should condition your
RewriteRuleto prevent the looping, perhaps as follows:Also, your
ErrorDocument 500statement doesn’t make much sense, as you will never generate a 500 error because you don’t havemod_rewriteenabled, since you’ve surrounded the relevantmod_rewritedirectives with<IfModule mod_rewrite.c>.