Search code examples
php.htaccessmod-rewrite

Mod rewrite keeps appending GET string when no backslash at the end is present


RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?route=$1

With that rewrite rules, if I enter any link that doesn't end in a backslash, GET string is appended at the end.

Examples:

localhost/forum/ shows as localhost/forum/

localhost/forum shows as localhost/forum/?route=Forum


Solution

  • add a line RewriteCond %{REQUEST_FILENAME} !-d

    so it won't do anything when an exsisting directory is pointed at