Get Redirect URL with cURL
URL redirects can be glorious or annoying depending on which side of them you are on and which side you want to be on. Redirects are helpful for vanity URLs (useful in advertising) but sometimes they're annoying in that they could potentially break your code if you encounter a redirect you weren't anticipating.
The useful and amazing cURL command line utility allows you to fetch an address and return its final destination URL:
# "/css" doesn't exist but WordPress tries to find the closest match
# and then redirects to it ("/css-animation-callback")
curl -Ls -w %{url_effective} -o /dev/null https://davidwalsh.name/css
# Outputs: https://davidwalsh.name/css-animation-callback
The url_effective
variable is what we're after. The L
directive tells cURL to follow redirects, the s
directive tells cURL to be silent (i.e. not output the page contents). You provide the URL, cURL follows it to its endpoint -- easy!
Kids these days, I tell ya. All they care about is the technology. The video games. The bottled water. Oh, and the texting, always the texting. Back in my day, all we had was...OK, I had all of these things too. But I still don't get...
CSS animations aren't just for basic fades or sliding elements anymore -- CSS animations are capable of much more. I've showed you how you can create an exploding logo (applied with JavaScript, but all animation is CSS), an animated Photo Stack, a sweet...
There's nothing like a subtle, slick website widget that effectively uses CSS and JavaScript to enhance the user experience. Of course widgets like that take many hours to perfect, but it doesn't take long for that effort to be rewarded with above-average user retention and...
A few weeks back, jQuery expert Janko Jovanovic dropped a sweet tutorial showing you how to create a Skype-like button using jQuery. I was impressed by Janko's article so I decided to port the effect to MooTools.
The XHTML
This is the exact code provided by...
Follow a URL using JavaScript: https://www.npmjs.com/package/linkfollower