Using mod_rewrite, how would I take urls like these:
www.example.com/?foo=hello
www.example.com/?foo=world
and redirect them to urls like these:
www.example.com/hello/
www.example.com/world/
Thanks
Using mod_rewrite, how would I take urls like these:
www.example.com/?foo=hello
www.example.com/?foo=world
and redirect them to urls like these:
www.example.com/hello/
www.example.com/world/
Thanks
What you should be doing is the opposite of that. You make all URL links on your site look like the 'pretty' version (but don't change any other functionality), then you use mod_rewrite to make patterns that will match requests for a 'pretty' URL and show the appropriate 'ugly' url. A very simple example for your link...
RewriteEngine On
RewriteEngine ^([^/]+)/?$ /index.php?foo=$1
Update:
You can redirect in the opposite direction using...
RewriteEngine On
RewriteCond %{QUERY_STRING} ^foo=(.*)
RewriteRule ^index.php$ /%1/ [R=302]
Once you are happy it's working, you can change the 302 to 301 for a permanent redirect. If you combine this with the above example though you will get a 500 Internal Server Error since you will be creating a redirect loop.