What is YOURLS
YOURLS is a small set of PHP scripts that will allow you to run your own URL shortening service (a la TinyURL). You can make it private or public, you can pick custom keyword URLs, it comes with its own API. You will love it.
There's a WordPress plugin available for YOURLS, making integration with your blog a snap: create short URLs and tweet them automagically as you publish blog posts.
- Public (everybody can create short links) or private (your links only)
- Sequential or custom URL keyword
- Handy bookmarklet to easily shorten and share links
- Awesome stats: historical click reports, referrers tracking, visitors geo-location
- Neat AJAXed interface
- Developer API
- Friendly installer
Download YOURLS from Google Code
You can follow YOURLS' development on the revision list and get current snapshot using SVN
YOURLS is made by:
- Unzip the YOURLS archive
includes/config.php with a raw text editor (like Notepad) and fill in the required settings
- Upload the unzipped files to your domain
- Create a new database (see Configuration – you can also use an existing one)
- Point your browser to
Upgrade from YOURLS 1.3 or earlier
- Make a copy of your
- Delete all files including
.htaccess in YOURLS root directory
- Unzip the YOURLS archive, upload the files
config.php and fill in details. Don't start with your old config file, use the new sample config file.
- In your new
config.php, add the defines for
YOURLS_DB_TABLE_NEXTDEC you had in your previous config file
- Backup the database!
- Point your browser to
http://yoursite.com/admin/ and follow instructions
- After upgrade is well and over, remove the define
YOURLS_DB_TABLE_NEXTDEC from your config file
- I promise that during next upgrade you won't need to touch your config file again :)
Configuration (in includes/config.php)
your MySQL username
your MySQL password
The database name
The database host
The name prefix for all the tables YOURLS will need
Your (short) domain URL, no trailing slash
Timezone GMT offset
Private means protected with login/pass as defined below. Set to false for public usage
Allow multiple short URLs for a same long URL
Set to true to allow only one pair of shortURL/longURL (default YOURLS behavior), or to false to allow creation of multiple short URLs pointing to the same long URL (as bit.ly does)
A random secret hash used to encrypt cookies. You don't have to remember it, make it long and complicated. Hint: generate a unique one at http://yourls.org/cookie
A list of username(s) and password(s) allowed to access the site if private
Example: 'joe' => 'mypassword'
URL Shortening settings
URL shortening method: base 36 or 62. See FAQ for more explanations
A list of reserved keywords that won't be used as short URLs. Define here negative, unwanted or potentially misleading keywords
Example: 'porn', 'faggot', 'sex', 'nigger', 'fuck', 'cunt', 'dick', 'gay'
YOURLS_PRIVATE is set to true, you can still easily make your individual stat pages public. To do so, override the global private setting with:
YOURLS_PRIVATE is set to true, you can still easily make your API public. To do so, override the global private setting with:
YOURLS_NOSTATS is set to true, redirects won't be logged and there will be not stats available.
- A server with mod_rewrite enabled
- At least PHP 4.3
- At least MYSQL 4.1
- Note: YOURLS can also run on Nginx (Read more)
- Maximum length of long URLs to be shortened is 2000 characters
- Maximum length of custom keyword is 200 characters
- That makes about 8 sexdecillions of centillions of available URLs (seriously. That's a 355 digits number).
Difference Between Base 36 And Base 62 Encoding
- Base 36 encoding uses
- Base 62 encoding uses
- Stick to one setting, don't change after you've created links as it will change all your short URLs!
- Base 36 should be picked. Use 62 only if you understand what it implies.
- Consider Base 62 encoding a
Getting a short domain name for your YOURLS install
- Unless you plan on making it public, any shared hosting should be fine
- Domainr is a fun search tool that might inspire and help you
- Aim for exotic top level domains (.in, .im, .li ...), they're often cheap and a lot are still available. Gandi is a pretty comprehensive registrar, for instance.
YOURLS needs its own .htaccess
- You cannot install YOURLS and, say, WordPress, in the same directory. Both of them need to handle URLs differently
- If you want to install YOURLS on the same domain than your blog, give it its own (short) subdirectory, such as yourblog.com/s/ (for "short") or yourblog.com/x/ (for "exit")
If YOURLS generates 404 for your short URLs
- Make sure mod_rewrite is enabled with your Apache server
- Some (crappy) hosts such as GoDaddy or 1and1 need a small fix to .htaccess:
Feedback and bug reporting
- Please don't get in touch directly by mail or Twitter
- Raise an issue here and give all the details. Thanks!
Here are a few examples of sites running YOURLS with a unique design or concept
Funny domain name, nicely styled
Another YOURLS setup with a cute quote look
Gorgeous design listing latest links with a custom RSS feed (private use)
Mr Tech's public YOURLS setup, listing top links and some stats
Shorten 4 Charity, a public YOURLS setup with shortened links displayed within a frame containing ads for charities
John Girvin's YOURLS setup with all links in a sortable display
Examples of portals for your online self with links to your places (blog, Twitter) and your URL shortener
A nice domain name hack :)
Public YOURLS setup run by famous sex writer Violet Blue as "the internet's first and only sex-positive url shortener"
More stuff about or with YOURLS