2

I've read in several places that you should decide whether you want trailing slashes or no trailing slashes in your site URLs and stick to your choice consistently.

This makes sense, but which should I pick? Is there a convention I ought to follow, performance to be gained, or is it totally up to my taste?

(I notice that the StackExchange sites link without trailing slashes, but SE doesn't redirect if you add a slash.)

jnm2
  • 217
  • 2
  • 3
  • 11
  • Doesn't look like it. http://serverfault.com/questions/ doesn't redirect anywhere (I see it shortens it just for display purposes). – Matthew Flaschen Jun 01 '12 at 15:36
  • Oh, I see. All their site links have prefer the missing slash, but they don't redirect if you put one in manually. – jnm2 Jun 01 '12 at 15:38

2 Answers2

4

It doesn't matter - Pick one and stick with it.

With websites like the Stack Exchange network (and most modern sites with dynamic content) the URL is passed to software that does "things and stuff" with it to produce the page you see -- the URL should be formatted in a way that makes that back-end software happy.

The only case I can think of where the trailing slash matters is Apache's mod_dir "Trailing slash redirect", where leaving off the / on a directory results in a redirect (and thus a second HTTP request from the client). The mod_dir documentation explains why, and the consequences of not doing this, quite well.
If that extra HTTP request is a serious concern for you you may want to give this more thought, but it probably isn't a big deal these days.

voretaq7
  • 79,879
  • 17
  • 130
  • 214
1

It's really up to you. I would go for the trailing slash, but that is just me. Google also seem to be going for it. A lot of times people may quote your site and forget to but the slash, but an extra redirect every now and then won't be much of an issue.