Unable to remove query string in .htaccess rewrite

I have read many posts and documentation, and still cannot make this work. Probably missing something trivial.

I want www.domain.no/?id=val to rewrite to www.domain.no/index.php

The code in .htaccess is

RewriteEngine on
RewriteBase / 

# Test that pathname exists, and is NOT a directory.
RewriteCond %{REQUEST_FILENAME} !-d 
# Test that the pathname with a .php extension exists, and is a regular file.
RewriteCond %{REQUEST_FILENAME}.php -f 
# Test that a non-empty query string exists
RewriteCond %{QUERY_STRING} .
# Re-write to file with .php extension, without query string
RewriteRule ^(.*)$ $1.php? [L]

Any suggestions?


Source: apache

Leave a Reply