I tried having http://domain.com/user/foobar redirected to http://domain.com/user/index.php?id=foobar using the following code in .htaccess:
RewriteEngine On
RewriteBase /data
RewriteRule ^user/(.*)$ user/index.php?id=$1
But for some reason only index.php (not foobar) is returned to the script as ID.
I think mod_rewrite gets confused because of the existing folder name also matching the regex pattern. It works, however, after renaming the folder to _user and accordingly modifying the above code.
Take care that the rewrite rule in your
.htaccessis applied multiple times:So it always replaces your
idparameter withindex.php.You need to write a condition that if
index.phpis already requested, it won’t get rewritten, e.g. by checking if a file already exists: