Four Key Reasons to Learn Markdown
Back-End Leveling UpWriting documentation is fun—really, really fun. I know some engineers may disagree with me, but as a technical writer, creating quality documentation that will...
It’s 2012. We know it’s the World Wide Web. We don’t need to be reminded of
that by prepending www.
to the URL of every site we visit. In fact, the use of www.
as the
de facto subdomain of The Web was an accident. And
what’s more, it was deprecated back in August of 2003.
I am over www.
and hereby pledege to do my best to stop using it on the
portions of the Internet that I build. To be successful, I need the Ruby on
Rails-powered apps I create to also drop the dubs. The powerful
router in Rails 3 (and newer) makes this trivial. Peep this:
Let’s talk about what’s going on there…
That outermost constraints
block is a Rails routing constraint
that only matches requests where the host starts with www.
. When that
constraint is met, we match ALL THE PATHS and any HTTP verb. Upon making the match, we tell the router
to redirect the request to a new URL.
The new URL is whatever URL the request came in on, sans the leading www.
.
Easy peasy!
For starters, I’ll hold it against you. But then I’ll immediately get over it
and we’ll go back to being friends.
In fact, as a token of my friendship, I’ll show you how to redirect non-www.
requests to a www.
-version.
This works much like the first example, but in reverse. An incoming request
lacking a leading www.
matches our constraint and gets redirected to the same
URL prefixed with a www.
.
Also easy, just more dub-dubs.
www.
or not?Do you have a preference or just an argument? Let’s hear it!
Writing documentation is fun—really, really fun. I know some engineers may disagree with me, but as a technical writer, creating quality documentation that will...
Humanity has come a long way in its technological journey. We have reached the cusp of an age in which the concepts we have...
Go 1.18 has finally landed, and with it comes its own flavor of generics. In a previous post, we went over the accepted proposal and dove...