Re: php/apache url cleanup

From: Matthew Schumacher <schu@schu.net>
Date: Wed Dec 29 2004 - 17:14:46 AKST

Clay Scott wrote:
> i'm working on a little web-based app and i'm gettting annoyed with the mile-long urls that are generated from passing information from script to script. i'm trying to clean this up by eliminating the miles of ?foo=foo&bar=bar and replacing it with something sane and clearly readable.
>
> it's software for cataloging books so instead of having browse.php?art=Publisher i'm trying to change things to be www.host.com/browse/publisher. i've gotten it to work as long as i leave it as www.host.com/browse.php/publisher, but i want to get rid of the .php's completely.
>
> i tried adding a .htaccess file to the directories as such:
>
> RewriteEngine On
> RewriteRule book book.php
> RewriteRule browse browse.php
>
> it got the job done and i can properly view host.com/browse, but this prevents the scripts from getting variables from the url. my intention is to get it to where i can do www.host.com/book/213 and it'll display the details for book number 213 in my database. as i said, my only fix thus far is to type www.host.com/browse.php/213. i know it's possible, i've seen done on plenty of sites so if the explanation is a bit long-winded a link to a page explaining it or some proof-of-concept code would be greatly appreciated.
>
> thanks,
> ~clay
>

I very well may be wrong, (I haven't looked at it in a while) but I
think that your going to run into a lot of heartache trying to get
apache to work like that. I wouldn't be surprised if there was a way to
make it work, but your always going to be running the risk of some other
code/config later on not wanting to play nice.

On some stuff I have done I just make php parse all of my html documents
(which all use php code anyway) then do all of my vars in a server side
session variable. That way I can keep track of what is going on and the
only thing I pass back and forth to the client is the token and it's
automatic in php. One nice feature of this setup is that you always
know what the user did. Suppose the user sorted some data, then left
the screen and came back, the sort var is still set until it is
overwritten with new information so the user finds what they expect
instead of the data set back to the default sorting.

schu

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Wed Dec 29 17:14:59 2004

This archive was generated by hypermail 2.1.8 : Wed Dec 29 2004 - 17:14:59 AKST