i want to create a beautiful query string from long and easily understandable query string
for example
http://www.domain.com/play.php?a=10&b=20&c=30
first of all this is vary long query string and second it is understand able that value of a,b&c.
what i want is php function which convert whole query string to a=10&b=20&c=30
to some text like f4cdret4
and then i pass same like
http://www.domain.com/play.php?q=f4cdret4
and in play.php i again convert back f4cdret4
to a=10&b=20&c=30
i am trying to find some thing like that but many days searching no success.
Thanks
This is a BAD idea from a usability perspective. I as a user would be annoyed with you. I recommend you read about URL Design.
Also, sounds like you want to keep something from the user. If so it's not secure if you do something like
$url .= '?q=' . base64_encode(http_build_query($parms));
Generally speaking, you don't want to divorce your URL from any semblance of meaning for the user unless you are significantly shortening it for use in character-limited settings like a Twitter post.
That said, there are a few ways to implement this. You can:
Use htaccess to make pseudo-directories (a=10&b=20&c=30 becomes "mydomain.com/q/10/20/30")
RewriteEngine On
RewriteRule /q/(.*)/(.*)/(.*)$ /page/play.php?a=$1&b=$2&c=$3
You could use some string transformation functions to hide the real query string. Here is a simple example I came up with using bin2hex
and pack
<?php
$str = 'a=10&b=5&c=20&d=6';
$encoded = bin2hex($str);
echo $encoded;
echo "
";
echo pack("H*",$encoded);
?>
example You can use bin2hex
to encode it, and pack
to decode it.