NYCPHP Meetup

NYPHP.org

[nycphp-talk] Do you use Pretty URLs

Gary Mort bz-gmort at beezifies.com
Wed Dec 12 06:19:52 EST 2007


inforequest wrote:
> Of course I may be surprised by how advanced some of you are, but from 
> where I sit, even the new apps on the new frameworks suffer from the 
> same routing issues.
>
> If anyone is enjoying reliable, manageable, strict and pretty URLs on 
> one of the "modern frameworks" I'd like to hear about it. That means 
> content level control of "pretty" URLs, ability to manage redirection 
> (at the content level), and enforced one-URL-per-document.

I find Joomla + a SEF component comes pretty dang close, and if you 
remove the "breadcrumbs" feature support it can be almost 100%.

The problem isn't so much the framework, as that the individual 
components also have to support the framework.

Basically, you have a function Joomla will call to convert to/from SEF 
urls.  It's built in SEF is ugly though.  Than you have the SEF 
component that gives a better ruleset for SEF.  Finally, all those 
components have a simple mechanism to customize them component per 
component.

Now, control at the "content" level in what manner?  For example, I used 
an ad component for user profiles, and I wanted to remap it to use the 
person's name as the end of the url, and special beginnings for 
different categories.  About 20 lines of code and it was done, and this 
only because I was in a hurry and hardcoded a lot of rules that should 
be configurable.

What do you mean by redirection?

In any case, I don't think Joomla is unique in this manner, all the 
various routers provide the same goals and functions.

As for how to use Pretty URL's, it really depends on the need. 
If you have a disciplined structure legacy app, you can use mod_rewrite 
and not much else.  Maybe use obstart so you can postprocess the page 
generated and convert the ugly urls to their mod_rewrite formats.

Using routers is nice, but main issue I see is that most everything is 
built to be generic.

IE a router will maintain a list of pretty URL to internal URL entries 
in a table or the file system(or memcache) and so when a request comes 
into the system, the router has to remap it on the fly everytime.

This allows the router to work with Apache, lighty, IIS, etc.

But if you know you are using Apache, it seems a far better solution 
would be to have your router save the url to a mysql table in a format 
that Apache's mod_rewrite with mysql support can use(and then to work it 
out in such a manner as to consolidate rewrites as much as possible 
using regular expressions).  And if your using Lighty, do it in a manner 
Lighty can use.  Etc etc and so forth.

I think in the end, "pretty urls" in a corporate/business setting are 
going to be 60-80% generic, and than a small bit of customization for 
just their specific needs.  Thus leading to most people starting with 
generic and then upgrading later(which has it's own penalty, as if the 
business grew and is popular, you then need to maintain /both/ systems 
for legacy purposes)




More information about the talk mailing list