1. Home
  2. Computing & Technology
  3. PHP / MySQL

Setting Up A Short URL Forward
For an easier to remember URL

By Angela Bradley, About.com

Although having an automated site is great, sometimes the rather long URLs they generate for sub-pages aren't very user friendly. These long addresses are hard to put on business cards, or to pass along to friends.

To make them more friendly you could use one of the many, many short URL services, but most come with strings. Or you can setup something similar right on your own website, using a PHP forward. Here is how:

1.) Create an easy to remember file name or folder, such as http://www/yoursite.com/mylink.php or http://www.yoursite.com/link. If you are creating a folder, the file inside the folder that holds the code would should be named index.php

2.) Put this code into your file:

<?php
header( 'Location: http://www.yoursite.com/this/is/a/long/url/you/want/to/direct/to.php' ) ;
?>
Make sure you replace our long URL with the one you want to direct to.

3.) Upload the file, and share your new short URL with friends!

More PHP / MySQL Quick Tips
Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Step By Steps
  5. Short URL - PHP Short Address - Forward Short URL

©2009 About.com, a part of The New York Times Company.

All rights reserved.