Liam W
Liam W

Reputation: 1163

Is this possible using a rewrite rule, and if it is how?

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

Answers (1)

bytemask
bytemask

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

Related Questions