Right now, the following URLs are displayed:
www.mysite.com/account.php?username=$username
What I want is:
www.mysite.com/$username
I'm using the following code in my htaccess
file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /account.php?username=$1 [L,QSA]
But it doesn't work: URLs are the same as before.
What's wrong ?
Your rule does only this:
If someone requests www.mysite.com/$username
, internally server the resource at /account.php?username=$username
.
That's all. The syntax being RewriteRule <the URI that matches this> <gets internally rewritten to this>
So you have nothing that does anything about changing the URL. That's not how mod_rewrite works. What it sounds like you want is to be able to externally redirect the browser so that what's in the location bar changes. To do that, it's a lot more complicated:
RewriteCond %{THE_REQUEST} \ /account\.php\?username=([^&\ ]+)&?([^\ ]*)
RewriteRule ^ /%1?%2 [L,R=301]