NYCPHP Meetup

NYPHP.org

[nycphp-talk] Howto create custom URLs

Jiju Thomas Mathew lists at silmail.com
Mon Mar 26 13:49:41 EDT 2007


>
> regex replace, right? What about urls that are constructed
> dynamically in javascript? And I feel there must be other holes. Is
> there a way this can be done reliably, or am I just being paranoid?
>
>
Actually you would either redesign the package, such that you wont mess up
with
htaccess, mod_rewrite or any such sort of plugs, or use some kind of
internal plugs
which will always be a headache.

I was involved in a project where the web server was really a modest one
with
256MB ram and a pIII 800 processor yet, had a very huge database, but the
basic
thing is that the data seldom changes, ie, there may be additions, but
modifications
are not that frequent.

We had the folowing htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^projects/(.*)\.html projects.php?g=$1 [L]

we also had a projects folder which was writable by the webserver process.
now
the php script would get the $_GET['g'], which could be parsed to identify
which
section of the projects was being referred to, and the database content
would be
merged with the static and layout template, and finally the whole html page
is built
into one single varaible, which is written to 'projects/' . $_GET['g'] .
'.html', as well
as echoed.  So in a second request, the file will be fetched from the file
system.

Whenever the content in a particular section is modified, we just unlink the
related
html file, which will get generated in the first subsequent request.

The point which I wanted to emphasise is that you should consider redoing
the whole
package with the furl in mind, and you will start seeing that you will no
longer require
any plugs.

-- 
Jiju Thomas Mathew
http://www.php-trivandrum.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20070326/07147c31/attachment.html>


More information about the talk mailing list