Create Your Own Short URLs with Your Domain and YOURLS

YOURLS is an exceptionally coded script to create a short URL service on your own website, for your own use (such as dotresults.com/h72 or dotresults.com/link). There are other scripts out there, some with more eye catching interface designs, but YOURLS is the most simple and quick way to do this. Installation is easy and configuration is a breeze. You’ll be up and running within five minutes. This tutorial is for those of you who want a private service for your own use – not a publicly available URL shortener.

1. Download the latest YOURLS package at: http://code.google.com/p/yourls/downloads/list

2. We recommend to use your main public_html directory to upload the files, because adding another folder defeats the goal of having the shortest URL possible. site.com/gh6 is much better than site.com/urls/gh6.

IMPORTANT: This advice is for just about any website that does not already have URL handling in place. Please see the note at the bottom of this post.

There are things you want to keep in mind when uploading YOURLS into the main directory of an existing website.

  • An index.html file is in the YOURLS package so if you happen to have an .html page and not index.php, be sure you do not overwrite your existing page.
  • Do not upload the .htaccess file. You likely already have one and this one is meant for a separate subfolder, not an existing website.
  • You probably already have /css, /js and /images folders, so upload the files inside of those folders separately. Some FTP programs decide to replace everything when it comes to subdirectories.

3. Next up is creating a database. Here’s a quick way to create a db if you have SSH access with your host:

mysql

create database yourdatabasename;

grant all privileges on yourdatabasename.* to 'username'@'%' identified by 'password';

For more info on how to use MySQL commands: http://dev.mysql.com/doc/refman/5.1/en/adding-users.html

4. Navigate into your /includes folder and rename config-sample.php to config.php. Then edit the file to set database information, installation URL and add a user and password: http://yourls.org/#Config

5. In your browser, visit site.com/admin to begin your installation. All should go smoothly and you can begin making URLs right away.

6. You will need to edit your .htaccess file if YOURLS is not working correctly. If you do not already have a .htaccess, you must place it into your main directory (not into /admin). Likely the contents of the file should be the lines below. If you can’t get it working, please feel free to leave a comment here so we can help out.

# BEGIN YOURLS
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9A-Za-z]+)/?$ /yourls-go.php?id=$1 [L]
RewriteRule ^([0-9A-Za-z]+)\+/?$ /yourls-infos.php?id=$1 [L]
# END YOURLS

7. You can always log into site.com/admin to create URLs and make stats easily. But there are other ways to create the URLs. There is a bookmarklet available in the Tools section of /admin.

Important Note:

If your site uses WordPress (or similar publishing platform) in the main public_html directory, you do have to create a separate subfolder to use YOURLS. This is because WordPress and YOURLS cannot share the same .htaccess file. The instructions above assume that your blog is installed at /blog for example and your main site is free to make additions to.

Another option is getting another domain name just for YOURLS. Then you do not have to worry about existing .htaccess requirements.

We think the most attractive way to combine WordPress, YOURLS, Twitter and your domain is to have your blog installed normally at site.com, YOURS installed at x.site.com as a subdomain or a separate domain. Then you can easily use the WordPress plugin available for YOURLS: http://wordpress.org/extend/plugins/yourls-wordpress-to-twitter

Share

14 Comments

  1. Hi,

    I’ve been struggling with this for a few hours, but I keep getting 403 errors

    I’m trying to install this on a site hosted at Nearly Free Speech. The highest directory it will let me save the .htaccess file into is /home/public/ – the yourls folders and files are stored in home/public/yourls.

    I’ve tried adding every combination of the folders that make up that path after the RewriteBase / section.

    I’ve also tried moving the .htaccess file between the /home/public/yourls and home/public folders, which seems to make no difference.

    I can’t help feeling I’m missing something very obvious. Do you have any ideas of anything I should check?

  2. marco

    i’m having a good 404 ALWAYS!!

    look like it’s working and actually writes onto my db

    but every url created doesn’t exist

  3. rea

    I lik it when people get together aand shade ideas. Great site, continue the good
    work!

  4. Hmm it seems like your website ate my first comment (it was super long) so I guess I’ll just sum it up what I wrote and say, I’m thoroughly enjoying your blog. I as well am an aspiring blog writer but I’m still new to everything. Do you have any points for inexperienced blog writers? I’d really appreciate it.

  5. Wonderful work! This is the kind of information that are meant to be shared across the web. Disgrace on the seek engines for now not positioning this publish higher! Come on over and discuss with my site . Thank you =)

  6. Thanks for your personal marvelous posting! I certainly enjoyed reading it, you happen to be a great author.I will be sure to bookmark your blog and will come back later in life. I want to encourage that you continue your great work, have a nice morning!

  7. I must thank you for the efforts you have put in penning this blog. I’m hoping to check out the same high-grade blog posts by you later on as well. In fact, your creative writing abilities has motivated me to get my very own site now 😉

  8. Sweet blog! I found it while browsing on Yahoo News. Do you have any tips on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Thanks

  9. There’s certainly a lot to know about this issue. I like all the points you made.

  10. A motivating discussion is worth comment.
    I believe that you ought to write more on this subject matter,
    it may not be a taboo matter but usually people do not talk
    about these topics. To the next! Many thanks!!

  11. My brother recommended I might like this blog.
    He was entirely right. This post truly made my
    day. You can not imagine just how much time I had spent for this info!

    Thanks!

  12. Definitely beslieve that that you stated. Your favourite reason appeared to be on the net the easiest factor to
    keep in mind of. I say to you, I certainly get irked while peiple think about worries thst
    they plainly do not understand about. You controlled
    to hit the nail upon the top and also defined out
    the entire thing without having side-effects , other folks can take
    a signal. Will probably be again to get more. Thanks

    My blog – Make Money forex online (http://www.themexicanlondoner.com)

  13. Thanks for sharing your thoughts. I trully appreciate your efforts and I am waiting for
    your next write ups thanks once again.

    my web site; therapy for hair loss (Shoshana)

I'm a photographer and business owner in Portland, Oregon. Yes, we moved here because we watched Portlandia, and because, mountains. My background includes web hosting and marketing. Feel free to ask me any questions about the articles on this website by using the contact page. Also please visit our sponsor: Unlimited VPN Service to increase your online privacy for as low as $5 a month!

251 views