Reputation: 41219
I have a long url in the following format
example.com/user.php?uname=foo&pass=bar
the problem with this url is that it is not at all memorable,
So I want to change it into a search engine friendly url
example.com/foo/bar
I have tried this rule in my htaccess that is on the web root
RewriteRule ^([a-zA-Z0-9]+)([a-zA-Z0-9]+)/?$mysite.com/user.php?uname=$1&pass=$2
but the problem is that its not working ,It redirects every page requests to 404 not found.
Any ideas?
Upvotes: 0
Views: 576
Reputation: 51711
Try this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/?$ /user.php?uname=$1&pass=$2 [QSA,L]
The conditions make sure you don't rewrite any existing file/directories on the server.
Upvotes: 2