[Owncloud] urlrouting

Roland van Laar roland at micite.net
Fri Mar 16 09:09:01 UTC 2012

On 03/15/2012 03:44 AM, Frank Karlitschek wrote:
> On 15.03.2012, at 00:47, Roland van Laar<roland at micite.net>  wrote:
>> On 03/14/2012 01:49 PM, Frank Karlitschek wrote:
>>> On 14.03.2012, at 01:46, Roland van Laar<roland at micite.net>   wrote:
>>>> A dispatch.php is added which becomes the starting point for all non img,ajax, css and js requests.
>>>> dispatch.php contains the starting point for urls.
>>>> An example url patterns:
>>>> $urlPatterns = Array(
>>>>     Array('url' =>   '^/$', 'file' =>   'index.php'),
>>>>     Array('url' =>   '^/index.php$', 'file' =>   'index.php'),
>>>>     Array('url' =>   '^/files', 'dir_include' =>   'files/'),
>>>> );
>>>> It's possible to include urls.php files in other directories via the
>>>> 'dir_include' =>   dir_name syntax in the Array.
>>>> The code: https://gitorious.org/~rvanlaar/owncloud/rvanlaars-owncloud-urlrouting
>>>> What do you think?
>>>> Is this something that has the potential to be included in owncloud?
>>> I´m really sorry to say but I think that your proposal is not suitable for ownCloud at the moment.
>>> I hate to say this to a new contributor but I hope you understand the reason.
>> I do understand it. One of the reasons I published the code now is to get feedback.
>> In the ideal case the dispatch code would be a class OC_route in lib.
>> That  way the code would be cleaner and tie in with the OwnClouds class loader.
>> How can this code become suitable for OwnCloud?
>> And is urlrouting something that could be incorporated in OwnCloud?
> I think urlrouting is a good idea in general. The challenge here is that ownCloud should run on different webservers and with minimal external dependencies.
> If it´s possible to implement this in a way that we don´t loose existing users than I´m fine with it. But I doubt that this is technically possible to be honest.

I have found a way to implement it in a way it's possible to use url 
routing and to have it work for others.

In dispatch.php useURLRouting is defined.
To allow for a correct base/lib.php path for the require_once the 
following coded is use:

if (defined('useURLRouting')){
     require_once 'lib/base.php';
} else {
     require_once '../lib/base.php';

Have a look at the code: 
The main files are dispatch.php, lib/route.php and a couple of urls.php 
A new install of owncloud with apache will set up the correct .htaccess 

There are some changes:
- A 404 is returned when a url is not matched
- some code is moved to OC_Route.


Roland van Laar

More information about the Owncloud mailing list