How does ez publish parse fancy "/obj1/obj2/obj3" URL's through one design script ? possible to do in PHP ?

Author Message

Armen Zourabian

Tuesday 29 June 2004 3:39:17 am

Hi All!

I noticed that ezPublish, which is implemented in PHP, gives a site very nice looking subdirectory structure like www.mydomain.com/users/amn/ or /forums/php/php4/iis... and the best if it all is that none of these directories actually exist at the site, only URLs look like that and they work. I would like to have a similiar site structure, and somehow detect which URL subdirectory is requested but control it all through a centralised script. Is it possible ? I know that in ez, each virtual url subdirectory represents an object. I want to know how to create such framework in PHP, only the part of it which uses one script template for all URL's of a domain, without having the directories actually corresponding to that URL.

My reasons are that it is much easier for people to remember such URLs, but I don't wont to create physical directories with subdirectories, because a lot of my sites content (design, style sheets etc) is shared for all pages, and distributing them across directories is a waste of time, resources, redundancy and space. Instead, I would like to keep the URL structure, but have it all go to one or two scripts at the root of the site or something which will parse the url with its "/"'s accordingly and make some sense out of it..

Thanks in advance,
Amn.

Bård Farstad

Tuesday 29 June 2004 4:09:55 am

This is actually rather simple to make. What we do is to store an alias for all objects. When we store an object we generate the "path" to that object based on the names of the parents (e.g. /frontpage/news/latest_news ). This name is converted into only valid characters.

When you request a page eZ publish will first check if there exists an alias for the current url, if it does it will look up in this alias to see which "page id" it should use.

--bård

Documentation: http://ez.no/doc

Armen Zourabian

Tuesday 29 June 2004 4:48:43 am

Takk for svaret bård ;)

But then again, yo explained the other half of the function, but how does the server know which file to send when you request an URL of "/obj1/obj2/obj3" ? Usually server map virtual directories to physical directories on the server disk, but in ez case, they are completely virtual maps ? That is what I am interested in. I would like to create similiar framework in PHP, and do not want to create directories called obj1, obj2 or obj3...

And since you mentioned that "ez publish checks the alias", this already implies that whatever URL, the request is sent to one master script right which does this checking?

Bård Farstad

Tuesday 29 June 2004 5:02:21 am

We use apache rewrite rules so all requests are sent to index.php. In this file we simply check if the requested uri e.g. /obj1/obj2/obj3 is in our alias table, if so -> then serve that page.

We use the $_SERVER['REQUEST_URI'] variable in PHP for fetching the current URI.

--bård

Documentation: http://ez.no/doc

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.