- Code: Select all
# Make sure /test/directory/filename.php exists.
RewriteCond %{DOCUMENT_ROOT}/test/$1$2.php -f
# Make sure it's in the format /optional-directories/filesname/filenamenumbers.
RewriteRule ^(.+/)?([^/]+)/\2([0-9]+)$ /test/$1$2.php?id=$3 [QSA,L]