Title says it all im having trouble rewriting the following urls
The original URL: example.com/user.php?id=username
The rewritten URL: example.com/username
My .htcacess
code is:
RewriteEngine On
RewriteRule ^([^/]*)$ /user.php?id=$1 [L]
What the issue?
The rewrite engine will loop, which means the rewritten URI (/user.php
) matches the same pattern and gets applied again. Try adding some conditions:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)$ /user.php?id=$1 [L]