View Single Post
Old 01-28-2010, 04:38 PM  
cyber
Confirmed User
 
cyber's Avatar
 
Industry Role:
Join Date: Jan 2004
Posts: 182
Also, if anyone is interested in only the short links without all the other tracking information:

You can have very, very short links like this:

http://www.cutiesr.us/a/4305

That go to their corresponding posts. #4305 is the post's ID, and goes here:

http://www.cutiesr.us/4305-erica-won...fect-tits.html

(your perma link will change depending on your settings, of course).

All you need is the following ...

Create folder "a" in your root.

Inside, create two files, ".htaccess" and "index.php"

Inside the .htaccess file, put:

Code:
Options +FollowSymlinks
RewriteEngine On

RewriteRule ^([0-9]+)$ /a/index.php?id=$1 [R=301,L]
inside index.php put:

PHP Code:
<?
// URL variables
$id = $_GET['id'];
if(!ctype_digit($id)){header("Location: /");}
// Include base WP files and connect to DB
include('../wp-config.php');
mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die(mysql_error());
mysql_select_db(DB_NAME) or die(mysql_error());
$result = mysql_query("SELECT * FROM {$table_prefix}posts WHERE ID='{$id}' LIMIT 1");
$row = mysql_fetch_assoc($result);

$url = get_permalink($id);
header("Location: {$url}");
exit();
And whala, you've got your very own short URLs!

edit: hi fris!
cyber is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote