Re: Reformatting the URI on return to the browser

From: Date: Thu, 14 Jun 2007 13:59:16 +0000
Subject: Re: Reformatting the URI on return to the browser
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-256993@lists.php.net to get a copy of this message
On 6/13/07, Robert Cummings <robert@interjinn.com> wrote:
On Thu, 2007-06-14 at 12:17 +0900, Dave M G wrote: PHP, I've implemented "friendly urls" in my PHP scripts, so that people can type in things like: http://website.com/Cats And Dogs ... and they'll be taken to the right page. However, when they get to the page, the url will read: http://website.com/Cats%20And%20Dogs Not so pretty. I've noticed that Wikipedia will alter the URI to become more readable, by replacing the spaces with underscores, like so: http://wikipedia.org/wiki/Cats_And_Dogs I'd like to be able to do that with my system, but I can't quite figure out where in the process of getting a URI request and returning a page that the URI will get set. Can anyone help me with figuring out at what point I can gain control over the URI sent back, as Wikipedia does? If you're on a linux box you can use:
    wget -S "http://en.wikipedia.org/wiki/scripting language"
... to see an example of what Wikipedia does. But to expound... :) Wikipedia issues a 301 (permanently moved) response header (don't tell Richard Lynch ;) thus redirecting your browser to the underscore version. Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
In tandem to Robert's post regarding the 301 (or 302, to be fair ;-P) HTTP response, you should also check into Apache's mod_rewrite. I still remember the quote by heart, but not who said it:
       "Despite the tons of examples and docs, mod_rewrite is voodoo.
Damned cool voodoo, but still voodoo." -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107

« previous php.general (#256993) next »