Is it safe to depend on trailing slash URLs for routing purposes?

I am creating a website with products, each of which belongs to one or more categories that can be nested in the parent categories. I would like to have SEO oriented URLs that 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 having a trailing slash to distinguish cases 2 and 3? Can I always assume that a user wants to index a category when a trailing slash is detected, compared to a specific product page without a trailing slash?

I am not worried about implementing this URI scheme; I have already done a lot with PHP and mod_rewrite. I just wonder if anyone knows of any objections to such URL routing. Are there any known issues with browsers clearing / adding return URLs from the address bar or with search engines crawling such a site? Any SEO issues or other stumbling blocks I'm likely to encounter?

+5
source share
5 answers

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

, "" "mysite.com/category/product" "mysite.com/category/all/product"?

+5

, http://product/ http://product . , URL hackable, , .

, RFC 3986 (URI): , 6.2 .4, , -:

. URI. , , URI,

http://example.com/data

URI,

http://example.com/data/

, , . (...)

+5

, , - . :

  • mysite.com/category/
  • mysite.com/category/product.html
  • mysite.com/category/sub-category/
  • mysite.com/category/sub-category/product.html

.

+3

, -, URL-.

, , URI . , , , .

+1

This question suggests that adding a trailing slash to the URL creates a URL that links to another resource. This is not true; The semantics of URLs are that they both refer to the same resource. The presence of a trailing slash in the base URL simply changes how relative URLs are interpreted using that base URL.

0
source

All Articles