cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vadim Gritsenko <va...@reverycodes.com>
Subject Re: Pros and cons of extension less requests (was Re: Url without extensions - how to match/rewrite)
Date Fri, 14 Dec 2007 20:58:06 GMT
On Dec 10, 2007, at 11:34 AM, Thorsten Scherler wrote:

> On Mon, 2007-12-10 at 10:00 -0500, Vadim Gritsenko wrote:
>> On Dec 10, 2007, at 3:40 AM, Thorsten Scherler wrote:
>>
>>> I ended up with:
>>>
>>> <!-- This will match all extension less requests -->
>>>     <map:match type="regexp" pattern="^[^.]+$">
>>>       <!-- This will match all requests having "/" on the end -->
>>>       <map:match type="regexp" pattern="^(.*)/$">
>>>         <map:match pattern="*/">
>>>           <map:redirect-to uri="../{1}.html" />
>>
>> This is a browser redirect, so user will ultimately see .../foo.html
>> URL in the browser. In this case, why would you start with a URL
>> without extension? I does not make any sense. Just use URL with
>> extension from the beginning.
>
> lol, tell it my client.
>
> The problem is when you do not do the rewrite

Solution's simple - since you really don't need them, just do not use  
such URLs at all :)


> you will end up to use
> absolute urls for all images, css, etc. since the client browser will
> interpret the "/" on the end as directory screwing up the relative
> imports. Meaning you have either lots of test whether or not we have  
> "/"
> on the end or do a rewrite.
>
>>
>>>         </map:match>
>>>         <map:match pattern="**/*/">
>>>           <map:redirect-to uri="../{2}.html" />
>>>         </map:match>
>>>       </map:match>
>>>       <map:match pattern="**/*">
>>>         <map:redirect-to uri="{2}.html" />
>>>       </map:match>
>>>       <map:match pattern="*">
>>>         <map:redirect-to uri="{1}.html" />
>>>       </map:match>
>>>     </map:match>
>>
>> Regardless of comment above, what you got here is too verbose, you  
>> can
>> DRY it down using smarter match pattern. For example:
>>
>>   <map:match pattern="^(?:[^.\/]*\/)*([^.\/]+)\/$">
>>     <map:redirect-to uri="../{1}.html"/>
>>   </map:match>
>>   <map:match pattern="^(?:[^.\/]*\/)*([^.\/]+)$">
>>     <map:redirect-to uri="{1}.html"/>
>>   </map:match>
>>
>
> Hmm, sorry but the above is not working for me.

I tested with the applet, was working fine. Probably you need to  
double up each '\' to work around sitemap escaping syntax.

Vadim


Mime
View raw message