Hi,

OK this one is a little embarrasing. I've been doing this for years and
I just wonder if I'm wrong....

Say you have an exit link on your site, e.g. /leave.php, which accepts a
"url" get arg. You use this page to record stats/whatever and then issue
a Location: header to take the user to the correct location.

Fairly standard yeah?

Well I've been doing something like:

$url = 'http://colin.guthr.ie/';
echo '<a href="/leave.php?url='.urlencode($url).'">Click</a>';

The logic in /leave.php does not need to call urldecode as it's done
automatically by PHP.

This has worked well for me in the browsers I've used (IE, FF etc.)

Recently, though, when using google webmaster tools I noticed that I was
getting a lot of 404's and this ultimately stemmed from the double
urlencoding of these url paramaters whereby the % signs used to encode
characters like / as %2F were encoded themselves leading to %252F. PHP
would automatically urldecode this to %2F but that still leaves me with
an encoded variable. Ugg.

So my question is, is the google bot just getting it wrong? Is it
reading the link and seeing a % and encoding it? Or is it finding a page
somewhere randomly on the interweb which has incorrectly double encoded
it and going from there?

It doesn't give you an referrer info which makes tracking down such
errors pretty tricky.... :(

I could just call urldecode manually, but I'm curious as to why I should
need to. Anyone fought with this before?

Col

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to