URL structure is the cornerstone of every website. It often dictates how long a website is usable and able to sustain itself through time. As SEOs, always concerned with search engines, we care about this. Perenniality is what we aim at… Or at least, we should.
Every once in a while, webmasters, SEOs and website owners erupt in heated discussions. We discuss between standards, best practices and what’s “better” for a website performance. We test and, as result, often assume our beliefs will be rewarded by search engines trough performance and, ultimately, better rankings.
We have discussed URL structure and the slash vs non-slashed URLs since forever. Heck! Even Google posted their take back in April 2010! Probably, amidst some controversy among webmasters and site owners.
Google treats each URL above separately (and equally) regardless of whether it’s a file or a directory, or it contains a trailing slash or it doesn’t contain a trailing slash
The process of designing a consistent website architecture, often dictates how long a website is usable, and able to sustain itself through time. As SEOs, always concerned with search engines, we care about this. Perenniality is what we aim at… Or at least, we should.
Servers don’t guess. It will work according to setup
At a barebones configuration, Apache assumes that directories end with a trailing slash, while files won’t. See below (emphasis mine):
If you request a directory without including the trailing slash in its name (i.e. http://example.com/dir rather than http://example.com/dir/), then Apache must send a redirect to add the trailing slash to the URL. This is necessary so relative hyperlinks will work in the resulting file.
When you have a barebones configuration, an
index of / listing, will serve you a virtually generated index file. This is a file the server processes for you — Unless you’re using a non-web interface like a terminal window or a system UI window. But this is not the expected behavior from a web interface. From a technical perspective, a web server does an “extra job” in generating the index file for a directory, than just serving the file.
Nevertheless, this is only true, if you don’t have a virtual hosting configuration or an
.htaccess file in place that states otherwise. And, whenever you have a web server configured, Apache will always check for these by default before serving anything to the user. So, the server will never decide how to display information, before checking for a configuration file. This, defeats the idea that, a server does extra work when requesting
https://foo/bar than it would, if the request would end with a trailing slash. Like
When a request is received, the server first maps it to the best matching
<VirtualHost>based on the local IP address and port combination only. Non-wildcards have a higher precedence. If no match based on IP and port occurs at all, the “main” server configuration is used.
From Core HTTP Apache.org
Good URLs help search engines… And their users
Even when URLs are friendly to search engines, they should fulfil yet another more important need: They should help users, by representing intuitively, the information they’re supposed to convey.
Clean URLs with no extension
Example of URL structure without file extension aimed at Usability and Human Perception:
Clean URLs with extension
Example of URL structure with file extension aimed at Usability and Human Perception:
When we look at a URL in our browser address bar, we intuitively assume folders are represented with a trailing slash at the end, while files are not (or have an extension). This is carved in our brains as basic functionality: Folders contain files; files come out of folders; files are the final information container.
Changing URL structure for SEO-only purposes, might not be the best approach most of the times.
Technicalities matter, but users matter more
We are always looking for ways to improve our websites. We want search engines to see how much we improved, and rank our websites above our competitors. But often we pursue myths, wrong assumptions, and things that don’t align with user expectation. This usually ends up in misleading ideas and advice.
Webmasters, SEOs and site owners need to make sure they’re doing thorough investigations and tackling real issues. For this to happen, we need to understand the real causes and effects before giving advice to others.