Kevin Nelson Marshall
Other entries:
« Catching my breath a little bit.

I'm hacking around on the email-to-twitter thing a bit tonight (almost done with version one so watch for that announcement probably tomorrow)...anyway as part of it, I needed to do some Apache rewrite stuff...and I thought it was cool enough that I would just share it up here as tonight's post.

Basically what I wanted to do was execute the code if the script exists...otherwise, I want to assume the user is attempting to access a message and is passing in a message key.

To accomplish this, I basically have to check if a file exists...if it does, just go to it, but if it doesn't take whatever was passed and use it as the key for the viewmessage.php script.

Of course I had to have mod_rewrite installed and enabled for apache2 ... but I'm not going to go into those details right now (do a google search for 'mod_rewrite apache' if you need help, the first few results will have all the gory details).

Anyway, here's the rules I put in place (that seem to be working pretty good so far):

RewriteEngine On

# Is the request for a non-existent file?
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([a-zA-Z0-9]+) viewmessage.php?id=$1 [NC]

posted by Kevin Marshall on 2009-07-29 00:00:00+00


Subscribe to my RSS feed »

BotFu feed with RSS reader

BotFu feed by Email


Search All Posts »


Kevin Marshall - Who's That?

I'm just your basic programmer. I can't spell to save my life, I'm not the greatest story teller, and I often ramble on about nothing. This blog showcases all of that!

If you're bored drop me an email at info at falicon.com or view my outdated resume.


Stalk Kevin on »

bit.ly
Delicious
Digg
Disqus
Facebook
Flickr
FriendFeed
Github
Last.fm
LinkedIn
StumbleUpon
Twitter (@falicon)

Archives by Category »

(28) Code »
(8) ColdFusion »
(15) Database »
(10) Factor »
(3) Falcons »
(321) General »
(13) JavaScript »
(18) Perl »
(17) PHP »
(20) Ruby »

Archives by Month »

(1) September 2010 »
(2) August 2010 »
(3) July 2010 »
(13) June 2010 »
(8) May 2010 »
(2) April 2010 »
(2) March 2010 »
(5) January 2010 »
(2) October 2009 »
(6) August 2009 »
(11) July 2009 »
(2) May 2009 »
(3) April 2009 »
(2) March 2009 »
(7) February 2009 »
(9) January 2009 »
(14) December 2008 »
(5) November 2008 »
(12) October 2008 »
(13) September 2008 »
(16) August 2008 »
(23) July 2008 »
(20) June 2008 »
(24) May 2008 »
(23) April 2008 »
(27) March 2008 »
(28) February 2008 »
(26) January 2008 »
(7) December 2007 »

Published Works »

Beginning Amazon's SimpleDB (Apress in dev.)
Pro Active Record (Apress 2007)
Web Services with Rails (O'Reilly 2006).

Contributed To »

Ruby Cookbook (O'Reilly 2006)
SQL Cookbook (O'Reilly 2005)
Various Reviews published in Computing Reviews

Free Code I've Created »

SimpleDB library in Python 3.0



This blog is powered by KickAssCode.