Pregunta

i have a site with a search form... when you type an apostrophe, the first results page is shown properly with only results which have an apostrophe in the name, but the links of the navigation bar don't work properly: the link is for instance http://example.com/search.php?q=%27&page=2 but when you click the link and the page loads it becomes http://example.com/search.php?q=%2527&page=2 and it confuses the results (yes i could use raw_url_decode() but the first results page would not be in line with the others, because the first should not be decoded)

Should i use some RewriteRules or something... ?

P.S. The same problem occurs if i simply do header("Location:http: //example.com/search.php=q=%27") even if i use raw_url_decode() on the '%27' string or raw_url_encode() or even url_encode() and url_decode()

Even if the solution for the results was in the decoding, i would like to show the URL i want to show, and i CAN'T actually send to a page with %27 in the URL because it always becomes %2527... so please tell me how to change the URL, not the results

Anyway you can see it by yourself by going to echidnavideos.it and searching just ' in the search bar... anf then try to go to page 2 or 3

¿Fue útil?

Solución

You can write some PHP code that will rewrite the occurrence of %2527 and %27 to an apostrophe. This should be done at the beginning of the code.

$newstring = str_replace("%2527", "\'", $_GET["q"]);
$newstring = str_replace("%27", "\'", $newstring);

So, do this:

// if navbar is needed
$q = str_replace("%2527", "\'", $q);
$q = str_replace("%27", "\'", $q);
if($pages > 1){

    $links = 1;
    $a = array();
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top