Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Dev

RT #24132: [WISH] redirect if missing trailing / from Catalyst root

 

 

Catalyst dev RSS feed   Index | Next | Previous | View Threaded


brian.cassidy at nald

May 28, 2008, 6:46 AM

Post #1 of 5 (499 views)
Permalink
RT #24132: [WISH] redirect if missing trailing / from Catalyst root

On behalf of "CDOLAN <cpan[at]chrisdolan.net> ":

CDOLAN <cpan[at]chrisdolan.net>

I'm running a Catalyst app at a non-server-root location, say
http://example.com/foo/. When accessing the app root properly with the
trailing slash, Catalyst correctly processes path '/'. However, when
requesting the URL without the slash (like http://example.com/foo)
Catalyst processes path '/foo' instead of '/'.

This is a common problem that can be solved via Apache redirect, but it
would be convenient if Catalyst could solve it by itself. I propose the
following trivial fix, but am unsure where it belongs in the code base:

if ($c->req->uri . '/' eq $c->req->base) {
$c->req->redirect($c->req->base);
return;
}

Perhaps this could even be a plugin that runs at the prepare_path phase?

An incorrect solution would be to internally pretend the URL had the
slash because that would break relative URLs (but you already knew that...).

--

The original RT ticket can be found here:

http://rt.cpan.org/Ticket/Display.html?id=24132

_______________________________________________
Catalyst-dev mailing list
Catalyst-dev[at]lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev


autarch at urth

May 28, 2008, 7:49 AM

Post #2 of 5 (469 views)
Permalink
Re: RT #24132: [WISH] redirect if missing trailing / from Catalyst root [In reply to]

On Wed, 28 May 2008, Brian Cassidy wrote:

>
> I'm running a Catalyst app at a non-server-root location, say
> http://example.com/foo/. When accessing the app root properly with the
> trailing slash, Catalyst correctly processes path '/'. However, when
> requesting the URL without the slash (like http://example.com/foo)
> Catalyst processes path '/foo' instead of '/'.

I don't get this. What is the differnce between a path of "/foo" and
"/foo/"? Looking at RFC3986 it's hard for me to tell if the spec intends
that they be considered as different paths.


-dave

/*==========================
VegGuide.Org
Your guide to all that's veg
==========================*/

_______________________________________________
Catalyst-dev mailing list
Catalyst-dev[at]lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev


ash_cpan at firemirror

May 28, 2008, 7:54 AM

Post #3 of 5 (470 views)
Permalink
Re: RT #24132: [WISH] redirect if missing trailing / from Catalyst root [In reply to]

On 28 May 2008, at 15:49, Dave Rolsky wrote:

> On Wed, 28 May 2008, Brian Cassidy wrote:
>
>>
>> I'm running a Catalyst app at a non-server-root location, say
>> http://example.com/foo/. When accessing the app root properly with
>> the
>> trailing slash, Catalyst correctly processes path '/'. However, when
>> requesting the URL without the slash (like http://example.com/foo)
>> Catalyst processes path '/foo' instead of '/'.
>
> I don't get this. What is the differnce between a path of "/foo" and
> "/foo/"? Looking at RFC3986 it's hard for me to tell if the spec
> intends that they be considered as different paths.
>
>
> -dave
>

In terms of hte spec, maybe nothing, but in practice

/foo is the file foo
/foo/ is the index file/aciton of the foo directory

Also consider the link <a href="bar">bar</a>

on /foo this will take you to /bar
on /foo/ this will take you to /foo/bar

I see the problem, but I'm not sure where the solution belongs (in
catalyst or a rewrite rule for your webserver).

-ash


_______________________________________________
Catalyst-dev mailing list
Catalyst-dev[at]lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev


pagaltzis at gmx

May 28, 2008, 9:11 AM

Post #4 of 5 (467 views)
Permalink
Re: RT #24132: [WISH] redirect if missing trailing / from Catalyst root [In reply to]

* Dave Rolsky <autarch[at]urth.org> [2008-05-28 16:55]:
> I don't get this. What is the differnce between a path of
> "/foo" and "/foo/"? Looking at RFC3986 it's hard for me to tell
> if the spec intends that they be considered as different paths.

They aren’t paths at all, and are in fact completely different
URIs. Whether they map to the same thing is for the server to
decide. From the outside, just from looking at the URI, you
cannot tell.

Regards,
--
Aristotle Pagaltzis // <http://plasmasturm.org/>

_______________________________________________
Catalyst-dev mailing list
Catalyst-dev[at]lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev


dbix-class at trout

May 29, 2008, 9:38 AM

Post #5 of 5 (455 views)
Permalink
Re: RT #24132: [WISH] redirect if missing trailing / from Catalyst root [In reply to]

On Wed, May 28, 2008 at 10:46:43AM -0300, Brian Cassidy wrote:
> On behalf of "CDOLAN <cpan[at]chrisdolan.net> ":
>
> CDOLAN <cpan[at]chrisdolan.net>
>
> I'm running a Catalyst app at a non-server-root location, say
> http://example.com/foo/. When accessing the app root properly with the
> trailing slash, Catalyst correctly processes path '/'. However, when
> requesting the URL without the slash (like http://example.com/foo)
> Catalyst processes path '/foo' instead of '/'.
>
> This is a common problem that can be solved via Apache redirect, but it
> would be convenient if Catalyst could solve it by itself. I propose the
> following trivial fix, but am unsure where it belongs in the code base:
>
> if ($c->req->uri . '/' eq $c->req->base) {
> $c->req->redirect($c->req->base);
> return;
> }
>
> Perhaps this could even be a plugin that runs at the prepare_path phase?
>
> An incorrect solution would be to internally pretend the URL had the
> slash because that would break relative URLs (but you already knew that...).

Memory saith the misdispatching is generally caused by a broken webserver
config. Andy (or anybody else), can you confirm or deny that?

Other than that, it looks like his proposed "incorrect solution" would be
the fix to an engine bug underlying this.

The whole redirect thing is certainly bollocks, although for people using
relative URLs it might be a useful cookbook entry to show how to do this
in a :Path('') action in Root.pm or something.

--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/

_______________________________________________
Catalyst-dev mailing list
Catalyst-dev[at]lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev

Catalyst dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.