Beantin webbkommunikation

Beantin Beta Blog

Experiments, investigations, and tests of web things
October 12, 2010

Generating automatic QR codes with YOURLS

When launched a few weeks ago, they included a feature where adding .qr to the end of a link produced a QR Code for the link. have started doing the same, using the same .qr extention. The idea being you can quickly generate a code, or transfer a link to your mobile device.

So this page for example is a with Google’s shortener, and as a QR code. Similarly with and as a 2d barcode.


I run my own hosted URL shortener using YOURLS on my domain. It doesn’t natively support the generation of QR code, but there was a discussion earlier in the year. The main result of that was an awkward “plug-in” which in my eyes over complicates the issue.

In reality it’s very straight forward. is my shortener link to this page, and produces a QR code


Just add the following line to the .htaccess file in your YOURLS installation directory. Add it as the first RewriteRule (ie before any YOURLS ReWriteRules).

RewriteRule ^([0-9A-Za-z]+).qr/?$
cht=qr&chs=200x200&chl=http://%{HTTP_HOST}/$1 [L]

Then that’s it. Job done!

It’s worth noting that this tip isn’t limited to YOURLS, it will work for any Apache based webserver (but check that the RewriteRule doesn’t clash with anything else you have setup).

Related Posts Plugin for WordPress, Blogger...


Filed under Configuration.

Tags: , , ,

Theme Beantin created by James Royal-Lawson. Privacy Policy