Is it safe to depend on a trailing slash in a URL for routing purposes?

url, url-routing

Solution

In addition to the other pitfall ideas you mentioned, the user might himself change the URL (by typing the product or category) and add/remove the trailing "/".

To solve your problem, why not have a special sub-category "all" and instead of "mysite.com/category/product" have "mysite.com/category/all/product"?

Problem

I'm building a site that has products, each of which belongs to one or more categories, which can be nested within parent categories. I'd like to have SEO-friendly URLs, which look like this: - mysite.com/category/ - mysite.com/category/product - mysite.com/category/sub-category/ - mysite.com/category/sub-category/product My question is: Is it safe to depend on a the presence of a trailing slash to differentiate between cases 2 and 3? Can I always assume the user wants a category index when a trailing slash is detected, vs a specific product's page with no trailing slash? I'm not worried about implementing this URI scheme; I've already done as much with PHP and mod_rewrite. I'm simply wondering if anybody knows of any objections to this kind of URL routing. Are there any known issues with browsers stripping/adding trailing URLs from the address bar, or with search engines crawling such a site? Any SEO issues or other stumbling blocks that I'm likely to run into?

Original source