My assumption was that urlencode solves the problem with all unwanted charachters in url but I have already faced 2 problems: 1. urlendoe cannot solve forwardslashe "/", by this I don't say that it cannot encode it but its encode is not effective, it replace "/" by "+%2F" which puting it in url return 404 error. 2. the second problem is with image urls, even when browsers can find the page, they cannot find the image with the same url encoded. Is my assumption wrong or something else I don't know?
well "/" encoded isn't "+%2F". There is no plus ("+"). It should be "%2F". If you are having trouble encoding your URLs, do one by hand to see if it works. If you get stuck for Hex values you can use the tables here : http://www.lookuptables.com. If you post the page with these problems so that the faulty URLs can be seen, that might help. Good luck.
Don't urlencode the whole url, just the query parameters. $query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar); echo '<a href="/path/goes/here?' . htmlentities($query_string) . '">'; PHP: if you are using PHP 5, you can do this: $url = '/path/goes/here?' . http_build_query(array('foo' => $foo, 'bar' => $bar)); echo '<a href="' . htmlentities($url) . '">'; PHP: