Reputation: 1163
I have set up a php script to receive url data like this:
http://giffgaff.liamwli.co.uk/?name=liamwli
I want to make it so that I can go to
http://giffgaff.liamwli.co.uk/liamwli
And it would be re-written accordingly.
I have tried multiple online generators and none worked, so how would I go about doing this?
Upvotes: 0
Views: 28
Reputation: 26
Remember that URL Rewrites are technically for URLs, not query parameters.
That said, there's a way to do this using RewriteCond to match on the QUERY_STRING:
RewriteCond %{QUERY_STRING} ^name=(.*)$
RewriteRule ^/$ /%1 [L,R=302]
This should grab the value of name and populate it in the rewrite rule.
EDIT Oh crap I got your request backwards. OK you actually want to do something like this:
RewriteRule ^/([^/]+) /?name=%1 [L,R=302]
Also, this is more of a ServerFault question since it's not really programming related.
Upvotes: 1