I just implemented a search function into my program. If a search string is sent, the program dose this:
if (isset($_GET['s'])) {
header('Location: /search/'.rawurlencode($_GET['s']));
exit;
}
The only problem I have is that the resulting search string URL isn’t really human readable, e.g. the search term is 500€ a lot of money results into is%20500€%20a%20lot%20of%20money. I would like to build a more human readable search URL, e.g. is+500€+a+lot+of+money.
Is there a simple way of doing this or do you have to encode the string manually, e.g. look for spaces, etc. and replace them.
Use
urlencodeinstead ofrawurlencode. This uses+for spaces rather than%20.