I want to rewrite URL and for that I have got following code.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?uname=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?uname=$1
now when I write url like http://www.mywebsite.com/username it works fine and not giving any error.
Now how can I get this URL even when I write http://www.mywebsite.com/index.php?uname=username in hit go.
I want to change http://www.mywebsite.com/index.php?uname=username to http://www.mywebsite.com/username when I write http://www.mywebsite.com/index.php?uname=username in URL.
As rewrite work for prefix of WWW I want same way to change my URL to http://www.mywebsite.com/username even if user write http://www.mywebsite.com/index.php?uname=username.
The following should work:
It will check if the file or directory doesn’t exist, and if it doesn’t it will assume it’s an username and rewrite the URL.
If you want to redirect from
index.php?uname=usernameto/usernamethen you could add this to the top of yourindex.php: