URL Rewrite Rules

Craig Lambie
Craig Lambie used Ask the Experts™
Hi Experts,

I am considering making a simple URL shortner service, in the style of bit.ly.

I am wondering on the easiest method of doing this URL re-writing.
I am familiar with .Net and a little PHP, and moving towards using more Open Source languages as I am falling in love with MySQL over MSSQL more and more.

I assume that it is a simple URL 301 redirect that happens when bit.ly creates a short URL, or a header redirect.

So my question is What server is best for SEO/ programming redirects - IIS or Apache?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
They both have good capabilities for creating 301 redirects, either by configuring the servers or by using scripts.  With Apache, 301 redirects can be written into the htaccess file, as long as mod_rewrite is enabled, or a header statement can be written into a codeblock on a page.

Every server/language can handle redirects, and my opinion is that none is really better than the other... the best one is the one you're most comfortable with, or the one you've got the equipment and software to run...


Thanks Andrew.
Do you know what language bit.ly or others are written in?
I sure don't.  There isn't any reason why you couldn't write a URL shortener in any language though... in order for a scripting language to be viable, it has to have the capabilities of doing whatever you want it to do...

I would expect that there are URL shorteners out there written in nearly every available language.
Acronis in Gartner 2019 MQ for datacenter backup

It is an honor to be featured in Gartner 2019 Magic Quadrant for Datacenter Backup and Recovery Solutions. Gartner’s MQ sets a high standard and earning a place on their grid is a great affirmation that Acronis is delivering on our mission to protect all data, apps, and systems.


Thanks for your contribution Andrew.
I am going to leave this question open for a day or two, I will allocate 250 points to you for your contribution, and if I get another answer, I will increase the points and distribute :)
Just to chime in here -- and not to nab points away from Andrew -- that I would think either IIS or Apache could handle them just fine, using most any language. But I would suspect that an Apache/PHP approach backed by a MySQL db would probably have the quickest response for redirects since it's just an innately lighter and less intensive sort of framework. Our main client uses YOURLS, which is an open-source URL shortener written in PHP backed by MySQL, and it absolutely flies for redirects which involve a DB query which then outputs the location redirect in PHP.

But for .htaccess redirects, or even redirects written directly into the Apache config itself, there is a really *very* little response time. It's not something you'll ever see the browser spinning on to wait for processing.

I haven't worked in depth with IIS7, but understand that you can now write rewrite rules a lot more like those in Apache, using regular expressions, etc. too.

Btw, to answer your question of what language BIT.LY is written in, I can't find the answer easily yet, but my guess is either Java or Python, which would scale really well and give the fastest possible response time -- way better than PHP at that uber-level of hits.
David S.Consultant & Challenge Subduer
Top Expert 2009
I wouldn't necessarily use Apache or IIS. I would definitely consider using Lighttpd or Nginx since they're designed to be more scalable than Apache.



Thanks to all for your contributions

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial