Closed DASPRiD closed 9 years ago
:+1:
The "search engines will see two URLs as the same resource" is not entirely true. I had this issue one day with CloudFront, which is Amazon CDN (but can be used also for dynamic content), and in its cache, "example.com" and "example.com/" are actually two different resources, and are stored in their cache as two different resources.
We may however add an option to the router so that it forces adding an ending slash.
@bakura10 This can be handled in HTTP server level, see https://github.com/Respect/Rest/blob/develop/public/no-slash.htaccess
@danizord So that was in favour of my idea to rtrim() incoming paths, correct?
@DASPRiD yes.
Well yeah, I agree that it makes more sense to do redirects on the server level, closing.
In ZF2, people had to be explicit about how trailing slashes in URLs are handled by their routes. Our strictness there was rather pointless, as search engines will see two URLs as the same resource when one ends with a slash and one doesn't.
The proposed solution is to simply
rtrim()
a possible trailing slash from the incoming path, except if the entire path only consists of a single slash.