.Htaccess Mod_Rewrite > 500 Internal Server Error

RewriteRule creating 500 Internal Server Error

Your code is guaranteed to generate 500 internal server error because it is causing infinite looping. Reason is that your matching URI pattern is: ^directory/(.*)$

Which matches your URLs before and after rewrites. And once it reaches max allowed internal rewrite limit Apache throws 500 internal server error and bails out.

Change your code to this:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^directory/(.*)$ directory/index.php?id=$1 [L,QSA,NC]

Above code has an extra RewriteCond %{REQUEST_FILENAME} !-f that will make sure to disallow subsequent execution of RewriteRule after first time since /directory/index.php will be a valid file.

500 Internal Server Error when using .htaccess with RewriteEngine

\xef\xbb\xbf are three invisible junk characters (at least from Apache's perspective) called the Unicode BOM, or byte order mark. Apache thinks that those characters are part of the command that follows right after. This is what you see in the log, though the characters are escaped so they're visible to the naked eye. \xef\xbb\xbfRewriteEngine

In your editor, especially if your editor is Notepad, make sure you're saving your file without a BOM. This should be selectable in the save as dialog or elsewhere.

Mod rewrite causing internal server error, error 500

That's because you have an infinite loop getting created over there, we need to put a condition to avoid that(I am checking if query string is NULL then only run the rule by that no infinite loop), try:

Also please make sure you clear your browser cache before checking your URLs.

RewriteEngine ON
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^([^/]*)$ /?paramOne=$1 [L]

.htaccess (mod_rewrite) 500 Internal Server Error

Try surrounding all your mod_rewrite directives in an ifmodule container:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^zip/([A-Z]*)/([a-zA-Z]*)$ zip.php?state=$1&city=$2 [L,QSA]
</IfModule>

If that fixes it, then you know you don't have mod_rewrite loaded. Otherwise, time to remove lines out of your htaccess file until you stop getting the 500 error.

.htaccess mod_rewrite 500 internal server error due to too many internal redirects from LimitInternalRecursion

Change your code with this:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

500 Internal Server Error when using .htaccess to always redirect to index.php

My docker-image is of php:7.2-apache and as it seems mod-rewrite wasn't enabled. Therefore after running the command a2enmod rewrite my website worked again.



Related Topics



Leave a reply



Submit