[UPHPU] URL Rewriting

MilesTogoe miles.togoe at gmail.com
Tue Apr 22 10:04:17 MDT 2008


Nathan Lane wrote:
> Thank you all - this will definitely get me started.
>
> On Tue, Apr 22, 2008 at 9:47 AM, Orson Jones <orson.uphpu at bookstore.usu.edu>
> wrote:
>
>   
>> Nathan Lane wrote:
>>
>>     
>>> I guess I just want to make my query strings more SEO compatible. I've
>>> seen
>>> a couple of MVC frameworks do this, like cakePHP - of course I guess
>>> because
>>> it is an MVC system, maybe it makes more sense. It writes the url as
>>> page.php/controller/function or something like that when you request it.
>>> Is
>>> this making any sense? Has anybody besides me heard of URL rewriting?
>>>
>>>       
>> It isn't too hard. I built some functions that strip the relevant data
>> out of $_SERVER. Mine were specific to a project, but looking through
>> the output of the following script and trying out several urls will give
>> you an idea of what to pull out.
>>
>> <pre>
>> $_SERVER[]
>> <?php print_r($_SERVER); ?>
>> </pre>
>>
>> The relevant ones seem to be SCRIPT_FILENAME, SCRIPT_NAME and REQUEST_URI
>>
>> Orson
>>
>>
>>     
There are two steps: first writing "clean" urls - as mentioned above 
mod_rewrite in ".htaccess" is what you want.  Then you need a main 
controller that parses the clean url to put the pieces into controller, 
action, and id variables.  Actually it's pretty simple code - but since 
I've switched over to python and ruby I don't remember the exact code I 
used but you can search on "clean urls" or "front end controllers" and 
there's several how-to articles on this - that's how I found it.   If 
you're really stuck let me know and I'll dig out the code I used. 


More information about the UPHPU mailing list