简体   繁体   中英

Pretty urls and trailing slashes

The question is about trailing slashes in URLs.

When we have a directory structure, then it is obvious - / means directory, no slash means resource.

However many sites are dynamic and use pretty urls that do not directly reflect their directory structure. And in this case most urls are actually requesting resources rather than directories, so a trailing slash is not needed.

My questions is: is it fine to have pretty urls not ending in a trailing slash, and if access to a trailing slash version is attempted to use a 301 redirect to the non-slash version?

And a counter question - is it fine to have all pretty urls end with a slash even though they are not directories?

Google says it's ok (for indexing and searching and all that)

However, they do mention that behavior like this is treated as duplicate content. So it's probably better that only one of those schemes actually refer to the content. You'd want one of the schemes to redirect to the other. Whether it should be the one with the trailing slash or not depends on your choice.

This article talks about this issue as well : http://www.standardzilla.com/2007/07/09/dont-forget-your-trailing-slash/ It recommends that you end with a trailing slash. But I think this is dependent more on how your server is setup than anything else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM