mod_rewrite change

View: New views
1 Messages — Rating Filter:   Alert me  

mod_rewrite change

by Matthew McNaney :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Good morning,

A couple of developers have asked for a change in mod_rewrite. Let me
show you the old and new methods.

Take this link:
index.php?module=uberpage&id=6&pg=13&flavor=maplenut

Currently phpWebSite would turn it into the following:

uberpage/6/13/maplenut

Nice and short, but no information on the value indexes. So you would
need to do the following in your uberpage module:

$_GET['var1'] = $id;
$_GET['var2'] = $page;
$_GET['var3'] = $flavor;

Otherwise you could recast the vars into the GET and REQUEST global var
directly:

$_GET['id'] = & $_GET['var1'];
etc.

You may also have to test for $_GET['var1'] using isset or test for
MOD_REWRITE_ENABLED.

In retrospect, probably not the most efficient method. Although I
considered the upcoming change initially, I was trying to keep the url
length down. In the end, I think I erred.

Here is the requested change. Take the same link:
index.php?module=uberpage&id=6&pg=13&flavor=maplenut

The new format would be:
uberpage/id/6/pg/13/flavor/maplenut

So now the link is longer but we have a more descriptive url. The
indexes are obviously paired with their value. The advantage of this
method is that it easily breaks down into $_GET values. The mod
developer doesn't need to parse $_GET['var(n)']. They will program the
same regardless of whether MOD_REWRITE_ENABLED is on or not.

I am experimenting on adding this change directly to the linkAddress
function. Therefore moduleLink and secureLink will automatically inherit
the change. This will make ALL links use the new style. In my testing,
admin links, that once ignored the mod rewrite, now work with mod_rewrite.

That said, all is not chocolate and roses. First, PageSmith, Block,
Blog, Menu and other content modules will need to check for the old link
versions in the database and fix them. Third party developers will need
to adjust as well. This may effect those without .htaccess or annoy IIS
admins further. Still, they will be able to disable MOD_REWRITE_ENABLED
as always, so they shouldn't be worse off than the previous version.

Respond here or in IRC with your concerns. I will be adding the changes
to subversion in the next couple of days. I hope some of you will have
time to test.

Thanks for your support and I appreciate the devs who brought this to my
attention.

Matt

--
Matthew McNaney
Electronic Student Services
Appalachian State University
Ext. 6493
http://ess.appstate.edu
http://phpwebsite.appstate.edu

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Phpwebsite-developers mailing list
Phpwebsite-developers@...
https://lists.sourceforge.net/lists/listinfo/phpwebsite-developers