Trailing slashes in URLs and HTTP redirects, SEO benefits
Posted: Wed Aug 29, 2012 10:57 am
When building HTML layouts I usually use relative URLs to pages such as /news or /archives. And when making redirects in .htaccess and PHP I always redirect to the URL without a trailing slash.
From an SEO perspective, should I actually be referring to URLs with a trailing slash at the end?
Google says it doesn't matter so long as you are consistent, otherwise I guess they will penalise you for duplicate content.
From a server perspective (Linux, Apache) not having the trailing slash means the destination could actually be either a file or a directory. Whereas with the trailing slash that can only be a directory and Apache serves the DirectoryIndex document for that directory.
I always make sure I 301 (moved permanently) redirect the URL with a trailing slash to the one without. So that should avoid duplicate content penalties.
But what's better as a general rule?
I don't mind either way, I'd just like to know if either type is preferred/recommended.
Cheers, B
From an SEO perspective, should I actually be referring to URLs with a trailing slash at the end?
Google says it doesn't matter so long as you are consistent, otherwise I guess they will penalise you for duplicate content.
From a server perspective (Linux, Apache) not having the trailing slash means the destination could actually be either a file or a directory. Whereas with the trailing slash that can only be a directory and Apache serves the DirectoryIndex document for that directory.
I always make sure I 301 (moved permanently) redirect the URL with a trailing slash to the one without. So that should avoid duplicate content penalties.
But what's better as a general rule?
I don't mind either way, I'd just like to know if either type is preferred/recommended.
Cheers, B