View Single Post
Old 10-28-2008, 11:55 AM   #3 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,347
Thanks: 5
Salathe is on a distinguished road
Default

It'll probably make more sense to use a regular expression to match short urls and throw them into the redirect page.

Code:
# Turn on URL rewriting
RewriteEngine On

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite to redirect.php
RewriteRule ^[a-z0-9_-]{4,7}$ redirect.php?url=$0 [NC,L]
Of course, the pattern might need changing to suit your own application as the one above might be a little too loose (or tight!) in what's allowed or not (alpha-numeric, underscore or dash between 4 and 7 in length (inclusive)).
Salathe is offline  
Reply With Quote
The Following 2 Users Say Thank You to Salathe For This Useful Post:
h0ly lag (11-01-2008), sketchMedia (10-28-2008)