A URL Policy for Web Projects
Post from August 22, 2013 (↻ June 1, 2017), filed under Web Development.
This and many other posts are also available as a pretty, well-behaved e-book: On Web Development.
Do your projects suffer from URL inconsistencies? I just noticed how mine do. I also noticed that I did some unnecessary things, like omitting protocols when they were actually useful. And I noticed that I’ve seen similar problems in corporate projects before. So I jotted down a quick “policy.”
Use the shortest available, non-redirecting URL. For example, make all site references relative if possible; root-relative URLs (
/foo) may be allowed on pages that serve as their own error pages. And, of course, omit “index.html” and other files names if they effectively serve as a DirectoryIndex. (Reason: more focused.)
Don’t omit the protocol unless the host site is available through both http and https. (Reason: faster—to avoid http to https redirects, assuming a http host site with links to target sites that live on https.)
Prefer https over http references. (Reason: more secure.)
Be consistent per site. (Reason: more maintainable.)
Mileage may vary, so this is more of an idea for other projects’ URL policies. Maybe you have a preference for absolute URLs. Maybe you have an SSL certificate, in which case you want to force https. Maybe you’re not as concerned about consistency. And maybe you see something that I missed, or found something to work better?
About the Author
Jens Oliver Meiert is a technical lead and author (sum.cumo, W3C, O’Reilly). He loves trying things, including in the realms of philosophy, art, and adventure. Here on meiert.com he shares and generalizes and exaggerates some of his thoughts and experiences.
If you have any thoughts or questions (or recommendations) about what he writes, leave a comment or a message.
Have a look at the most popular posts, possibly including:
Perhaps my most relevant book: CSS Optimization Basics (2018). Writing CSS is a craft. As craftspeople we strive to write high quality CSS. In CSS Optimization Basics I lay out the, at least some of the most important aspects of such CSS.
Looking for a way to comment? Comments have been disabled, unfortunately.