Hacker News new | past | comments | ask | show | jobs | submit login
Why Can’t Google Fix its Own URLs? (vineetdhanawat.com)
6 points by vineetdhanawat on Jan 21, 2012 | hide | past | favorite | 3 comments



It's a very common bug actually. When you use php_explode() for the REQUEST_URL for a case like '/webmasters/tools/submit-url' the array returned has a structure like array([0] => '', [1] => 'webmasters', [2] => 'tools', [3] => 'submit-url') Whereas in case of REQUEST_URL like '/webmasters/tools/submit-url/' the array returned has a structure like array([0] => '', [1] => 'webmasters', [2] => 'tools', [3] => 'submit-url', [4] => '') So, in the case with an extra '/' the length of aruguments increases and also the last argument becomes ''. Usually this is handled by busting the empty last and first array indexes. Thats why better to make your own function to decode urls when using them with .htaccess ;)


Question! I always assumed a URL is same with or without the ending / (forward slash). How can they behave differently?

The server just receives the URL from the client as a string; there's nothing in the protocol that requires a trailing slash to be ignored. Consider:

  if (REQUEST_URL == "/something") send_something()
  if (REQUEST_URL == "/something/") send_something_else()
Many web servers, such as Apache, helpfully adds a missing slash if it detects that the URL you're trying to access actually maps to a directory in the file system.


Oh, the I guess its same as doing via .htaccess file on a linux host.

But then surprisingly Google is returning a 404 error page to its own search result!




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: