You are viewing a plain text version of this content. The canonical link for it is here.
Posted to zeta-issues@incubator.apache.org by "Ronan Guilloux (JIRA)" <ji...@apache.org> on 2010/12/19 00:27:00 UTC

[jira] Created: (ZETACOMP-35) Trailing slashes in MvcTools URLs

Trailing slashes in MvcTools URLs
---------------------------------

                 Key: ZETACOMP-35
                 URL: https://issues.apache.org/jira/browse/ZETACOMP-35
             Project: Zeta Components
          Issue Type: Bug
          Components: MvcTools
         Environment: using Ubuntu 10.10, Apache2, Pear-installed Zeta Component local copy, PHP5, XDebug,
using Mvc Tutorial found here : http://incubator.apache.org/zetacomponents/documentation/trunk/MvcTools/tutorial.html
using MvcTools sandbox founded here : https://svn.apache.org/repos/asf/incubator/zetacomponents/docs/examples/applications/HelloMvc
            Reporter: Ronan Guilloux
            Priority: Minor


Well, it's more a documentation request than a "real" issue report :

Playing with the HelloMvc sandbox described in the Zeta's MvcTools Tutorial, I noticed that ezcMvcRouter doesn't manage yet the trailing slash at the end of URLs, such as in ~/foo/bar/

If you want to successfully route both ~/foo/bar and ~/foo/bar/, we have two solutions :

* (the more elegant) customize your apache conf adding

        <IfModule mod_rewrite.c>
        RewriteEngine  on
        #Redirecting /Foo/ to /Foo, /Foo/Bar/ to /Foo/Bar, & also /Foo/Bar/?i=1 to /Foo/Bar?i=1
        RewriteRule    ^(.*)/$  $1      [R=301,L]
        </IfModule>

* duplicate your routing rules & conf matchmaps

in router.php :
    (...)
    public function createRoutes()
    {
        return array(            
            new ezcMvcRailsRoute( '/:foo/:bar', 'mkController', 'fooBar ),
            new ezcMvcRailsRoute( '/:foo/:bar/', 'mkController', 'fooBar' ),
        );
    }
    (...)

and in lib/config.php
    (...)
    function createView( ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request, ezcMvcResult $result )
    {		
    	switch ( $routeInfo->matchedRoute )
        {
            case '/:foo/:bar':
                return new mkMuseumView( $request, $result );
            case '/:foo/:bar/':
                return new mkMuseumView( $request, $result );
        }
    }
    (...)

The first one being the more short & elegant way to me, I propose that it could be added as a tip inside the existing MvcTools tutorial.

And if I'm just misguiding myself, I humbly beg your forgiveness and silently go back to dive myself into php.net & httpd.apache.org/docs  ;-)

Ronan


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] [Commented] (ZETACOMP-35) Trailing slashes in MvcTools URLs

Posted by "James pic (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ZETACOMP-35?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13044781#comment-13044781 ] 

James pic commented on ZETACOMP-35:
-----------------------------------

First, i'll share how Django framework deals with it. There is a configuration option that causes requests to /foo to respond with a redirect to /foo/. I think that would be the way to go.

That said, i can see reasons for *not* actually supporting both urls. First, i think it's "just wrong" (tm) to have several URLs for the same resource. Second, if you want to do a static backup of the website, then you don't want URLs without trailing slashes, because your static HTTP server will rely on the static file extension to know what content type to serve.

For example, wget will make a "foo" folder with an "index.html" for /foo/. So you can visit static /foo/ and it'll work in the browser because the static webserver will serve /foo/ as text/html content type. But wget will make a plain text file for /foo. And your static webserver will not serve foo as text/html. So it won't work in the browser.

> Trailing slashes in MvcTools URLs
> ---------------------------------
>
>                 Key: ZETACOMP-35
>                 URL: https://issues.apache.org/jira/browse/ZETACOMP-35
>             Project: Zeta Components
>          Issue Type: Bug
>          Components: MvcTools
>         Environment: using Ubuntu 10.10, Apache2, Pear-installed Zeta Component local copy, PHP5, XDebug,
> using Mvc Tutorial found here : http://incubator.apache.org/zetacomponents/documentation/trunk/MvcTools/tutorial.html
> using MvcTools sandbox founded here : https://svn.apache.org/repos/asf/incubator/zetacomponents/docs/examples/applications/HelloMvc
>            Reporter: Ronan Guilloux
>            Priority: Minor
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> Well, it's more a documentation request than a "real" issue report :
> Playing with the HelloMvc sandbox described in the Zeta's MvcTools Tutorial, I noticed that ezcMvcRouter doesn't manage yet the trailing slash at the end of URLs, such as in ~/foo/bar/
> If you want to successfully route both ~/foo/bar and ~/foo/bar/, we have two solutions :
> * (the short way) customize your apache conf adding
>         <IfModule mod_rewrite.c>
>         #Redirecting /Foo/ to /Foo, /Foo/Bar/ to /Foo/Bar, /Foo/Bar/?i=1 to /Foo/Bar?i=1, & avoiding redirect loop on "/" (root view)
>         RewriteEngine  on
>         RewriteRule    ^/$      /       [L]
>         RewriteRule    ^(.*)/$  $1      [R=301,L]
>         </IfModule>
> * duplicate your routing rules & conf matchmaps
> in router.php :
>     (...)
>     public function createRoutes()
>     {
>         return array(            
>             new ezcMvcRailsRoute( '/:foo/:bar', 'mkController', 'fooBar ),
>             new ezcMvcRailsRoute( '/:foo/:bar/', 'mkController', 'fooBar' ),
>         );
>     }
>     (...)
> and in lib/config.php
>     (...)
>     function createView( ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request, ezcMvcResult $result )
>     {		
>     	switch ( $routeInfo->matchedRoute )
>         {
>             case '/:foo/:bar':
>                 return new mkMuseumView( $request, $result );
>             case '/:foo/:bar/':
>                 return new mkMuseumView( $request, $result );
>         }
>     }
>     (...)
> The first one being the more short & elegant way to me, I propose that it could be added as a tip inside the existing MvcTools tutorial.
> And if I'm just misguiding myself, I humbly beg your forgiveness and silently go back to dive myself into php.net & httpd.apache.org/docs  ;-)
> Ronan

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (ZETACOMP-35) Trailing slashes in MvcTools URLs

Posted by "Ronan Guilloux (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ZETACOMP-35?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13045049#comment-13045049 ] 

Ronan Guilloux commented on ZETACOMP-35:
----------------------------------------

Thanks a lot James for your analyse. 
To me, such comment should be now part of the existing MvcTools tutorial, as it lights the way for MVC begginers.

> Trailing slashes in MvcTools URLs
> ---------------------------------
>
>                 Key: ZETACOMP-35
>                 URL: https://issues.apache.org/jira/browse/ZETACOMP-35
>             Project: Zeta Components
>          Issue Type: Bug
>          Components: MvcTools
>         Environment: using Ubuntu 10.10, Apache2, Pear-installed Zeta Component local copy, PHP5, XDebug,
> using Mvc Tutorial found here : http://incubator.apache.org/zetacomponents/documentation/trunk/MvcTools/tutorial.html
> using MvcTools sandbox founded here : https://svn.apache.org/repos/asf/incubator/zetacomponents/docs/examples/applications/HelloMvc
>            Reporter: Ronan Guilloux
>            Priority: Minor
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> Well, it's more a documentation request than a "real" issue report :
> Playing with the HelloMvc sandbox described in the Zeta's MvcTools Tutorial, I noticed that ezcMvcRouter doesn't manage yet the trailing slash at the end of URLs, such as in ~/foo/bar/
> If you want to successfully route both ~/foo/bar and ~/foo/bar/, we have two solutions :
> * (the short way) customize your apache conf adding
>         <IfModule mod_rewrite.c>
>         #Redirecting /Foo/ to /Foo, /Foo/Bar/ to /Foo/Bar, /Foo/Bar/?i=1 to /Foo/Bar?i=1, & avoiding redirect loop on "/" (root view)
>         RewriteEngine  on
>         RewriteRule    ^/$      /       [L]
>         RewriteRule    ^(.*)/$  $1      [R=301,L]
>         </IfModule>
> * duplicate your routing rules & conf matchmaps
> in router.php :
>     (...)
>     public function createRoutes()
>     {
>         return array(            
>             new ezcMvcRailsRoute( '/:foo/:bar', 'mkController', 'fooBar ),
>             new ezcMvcRailsRoute( '/:foo/:bar/', 'mkController', 'fooBar' ),
>         );
>     }
>     (...)
> and in lib/config.php
>     (...)
>     function createView( ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request, ezcMvcResult $result )
>     {		
>     	switch ( $routeInfo->matchedRoute )
>         {
>             case '/:foo/:bar':
>                 return new mkMuseumView( $request, $result );
>             case '/:foo/:bar/':
>                 return new mkMuseumView( $request, $result );
>         }
>     }
>     (...)
> The first one being the more short & elegant way to me, I propose that it could be added as a tip inside the existing MvcTools tutorial.
> And if I'm just misguiding myself, I humbly beg your forgiveness and silently go back to dive myself into php.net & httpd.apache.org/docs  ;-)
> Ronan

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Updated: (ZETACOMP-35) Trailing slashes in MvcTools URLs

Posted by "Ronan Guilloux (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZETACOMP-35?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ronan Guilloux updated ZETACOMP-35:
-----------------------------------

    Description: 
Well, it's more a documentation request than a "real" issue report :

Playing with the HelloMvc sandbox described in the Zeta's MvcTools Tutorial, I noticed that ezcMvcRouter doesn't manage yet the trailing slash at the end of URLs, such as in ~/foo/bar/

If you want to successfully route both ~/foo/bar and ~/foo/bar/, we have two solutions :

* (the short way) customize your apache conf adding

        <IfModule mod_rewrite.c>
        #Redirecting /Foo/ to /Foo, /Foo/Bar/ to /Foo/Bar, /Foo/Bar/?i=1 to /Foo/Bar?i=1, & avoiding redirect loop on "/" (root view)
        RewriteEngine  on
        RewriteRule    ^/$      /       [L]
        RewriteRule    ^(.*)/$  $1      [R=301,L]
        </IfModule>

* duplicate your routing rules & conf matchmaps

in router.php :
    (...)
    public function createRoutes()
    {
        return array(            
            new ezcMvcRailsRoute( '/:foo/:bar', 'mkController', 'fooBar ),
            new ezcMvcRailsRoute( '/:foo/:bar/', 'mkController', 'fooBar' ),
        );
    }
    (...)

and in lib/config.php
    (...)
    function createView( ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request, ezcMvcResult $result )
    {		
    	switch ( $routeInfo->matchedRoute )
        {
            case '/:foo/:bar':
                return new mkMuseumView( $request, $result );
            case '/:foo/:bar/':
                return new mkMuseumView( $request, $result );
        }
    }
    (...)

The first one being the more short & elegant way to me, I propose that it could be added as a tip inside the existing MvcTools tutorial.

And if I'm just misguiding myself, I humbly beg your forgiveness and silently go back to dive myself into php.net & httpd.apache.org/docs  ;-)

Ronan


  was:
Well, it's more a documentation request than a "real" issue report :

Playing with the HelloMvc sandbox described in the Zeta's MvcTools Tutorial, I noticed that ezcMvcRouter doesn't manage yet the trailing slash at the end of URLs, such as in ~/foo/bar/

If you want to successfully route both ~/foo/bar and ~/foo/bar/, we have two solutions :

* (the more elegant) customize your apache conf adding

        <IfModule mod_rewrite.c>
        RewriteEngine  on
        #Redirecting /Foo/ to /Foo, /Foo/Bar/ to /Foo/Bar, & also /Foo/Bar/?i=1 to /Foo/Bar?i=1
        RewriteRule    ^(.*)/$  $1      [R=301,L]
        </IfModule>

* duplicate your routing rules & conf matchmaps

in router.php :
    (...)
    public function createRoutes()
    {
        return array(            
            new ezcMvcRailsRoute( '/:foo/:bar', 'mkController', 'fooBar ),
            new ezcMvcRailsRoute( '/:foo/:bar/', 'mkController', 'fooBar' ),
        );
    }
    (...)

and in lib/config.php
    (...)
    function createView( ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request, ezcMvcResult $result )
    {		
    	switch ( $routeInfo->matchedRoute )
        {
            case '/:foo/:bar':
                return new mkMuseumView( $request, $result );
            case '/:foo/:bar/':
                return new mkMuseumView( $request, $result );
        }
    }
    (...)

The first one being the more short & elegant way to me, I propose that it could be added as a tip inside the existing MvcTools tutorial.

And if I'm just misguiding myself, I humbly beg your forgiveness and silently go back to dive myself into php.net & httpd.apache.org/docs  ;-)

Ronan



> Trailing slashes in MvcTools URLs
> ---------------------------------
>
>                 Key: ZETACOMP-35
>                 URL: https://issues.apache.org/jira/browse/ZETACOMP-35
>             Project: Zeta Components
>          Issue Type: Bug
>          Components: MvcTools
>         Environment: using Ubuntu 10.10, Apache2, Pear-installed Zeta Component local copy, PHP5, XDebug,
> using Mvc Tutorial found here : http://incubator.apache.org/zetacomponents/documentation/trunk/MvcTools/tutorial.html
> using MvcTools sandbox founded here : https://svn.apache.org/repos/asf/incubator/zetacomponents/docs/examples/applications/HelloMvc
>            Reporter: Ronan Guilloux
>            Priority: Minor
>   Original Estimate: 0.17h
>  Remaining Estimate: 0.17h
>
> Well, it's more a documentation request than a "real" issue report :
> Playing with the HelloMvc sandbox described in the Zeta's MvcTools Tutorial, I noticed that ezcMvcRouter doesn't manage yet the trailing slash at the end of URLs, such as in ~/foo/bar/
> If you want to successfully route both ~/foo/bar and ~/foo/bar/, we have two solutions :
> * (the short way) customize your apache conf adding
>         <IfModule mod_rewrite.c>
>         #Redirecting /Foo/ to /Foo, /Foo/Bar/ to /Foo/Bar, /Foo/Bar/?i=1 to /Foo/Bar?i=1, & avoiding redirect loop on "/" (root view)
>         RewriteEngine  on
>         RewriteRule    ^/$      /       [L]
>         RewriteRule    ^(.*)/$  $1      [R=301,L]
>         </IfModule>
> * duplicate your routing rules & conf matchmaps
> in router.php :
>     (...)
>     public function createRoutes()
>     {
>         return array(            
>             new ezcMvcRailsRoute( '/:foo/:bar', 'mkController', 'fooBar ),
>             new ezcMvcRailsRoute( '/:foo/:bar/', 'mkController', 'fooBar' ),
>         );
>     }
>     (...)
> and in lib/config.php
>     (...)
>     function createView( ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request, ezcMvcResult $result )
>     {		
>     	switch ( $routeInfo->matchedRoute )
>         {
>             case '/:foo/:bar':
>                 return new mkMuseumView( $request, $result );
>             case '/:foo/:bar/':
>                 return new mkMuseumView( $request, $result );
>         }
>     }
>     (...)
> The first one being the more short & elegant way to me, I propose that it could be added as a tip inside the existing MvcTools tutorial.
> And if I'm just misguiding myself, I humbly beg your forgiveness and silently go back to dive myself into php.net & httpd.apache.org/docs  ;-)
> Ronan

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] [Issue Comment Edited] (ZETACOMP-35) Trailing slashes in MvcTools URLs

Posted by "James pic (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ZETACOMP-35?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13044781#comment-13044781 ] 

James pic edited comment on ZETACOMP-35 at 6/6/11 2:06 PM:
-----------------------------------------------------------

First, i'll share how Django framework deals with it. There is a configuration option that causes requests to /foo to respond with a redirect to /foo/. I think that would be the way to go.

That said, i can see reasons for *not* actually supporting both urls. First, i think it's "just wrong" (tm) to have several URLs for the same resource. Second, if you want to do a static backup of the website, then you don't want URLs without trailing slashes, because your static HTTP server will rely on the static file extension to know what content type to serve.

For example, wget will make a "foo" folder with an "index.html" for /foo/. So you can visit static /foo/ and it'll work in the browser because the static webserver will serve /foo/ as text/html content type. But wget will make a plain text file for /foo. And your static webserver will not serve foo as text/html. So it won't work in the browser.

Finally, please keep in mind that rails route are not really powerful. I myself wouldn't consider using anything other than the regexp route, which allows you to define one route for /foo/ and /foo with '/foo/?', or for /:foo/ and /:foo like this (?P<foo>.+)/?

      was (Author: is_null):
    First, i'll share how Django framework deals with it. There is a configuration option that causes requests to /foo to respond with a redirect to /foo/. I think that would be the way to go.

That said, i can see reasons for *not* actually supporting both urls. First, i think it's "just wrong" (tm) to have several URLs for the same resource. Second, if you want to do a static backup of the website, then you don't want URLs without trailing slashes, because your static HTTP server will rely on the static file extension to know what content type to serve.

For example, wget will make a "foo" folder with an "index.html" for /foo/. So you can visit static /foo/ and it'll work in the browser because the static webserver will serve /foo/ as text/html content type. But wget will make a plain text file for /foo. And your static webserver will not serve foo as text/html. So it won't work in the browser.
  
> Trailing slashes in MvcTools URLs
> ---------------------------------
>
>                 Key: ZETACOMP-35
>                 URL: https://issues.apache.org/jira/browse/ZETACOMP-35
>             Project: Zeta Components
>          Issue Type: Bug
>          Components: MvcTools
>         Environment: using Ubuntu 10.10, Apache2, Pear-installed Zeta Component local copy, PHP5, XDebug,
> using Mvc Tutorial found here : http://incubator.apache.org/zetacomponents/documentation/trunk/MvcTools/tutorial.html
> using MvcTools sandbox founded here : https://svn.apache.org/repos/asf/incubator/zetacomponents/docs/examples/applications/HelloMvc
>            Reporter: Ronan Guilloux
>            Priority: Minor
>   Original Estimate: 10m
>  Remaining Estimate: 10m
>
> Well, it's more a documentation request than a "real" issue report :
> Playing with the HelloMvc sandbox described in the Zeta's MvcTools Tutorial, I noticed that ezcMvcRouter doesn't manage yet the trailing slash at the end of URLs, such as in ~/foo/bar/
> If you want to successfully route both ~/foo/bar and ~/foo/bar/, we have two solutions :
> * (the short way) customize your apache conf adding
>         <IfModule mod_rewrite.c>
>         #Redirecting /Foo/ to /Foo, /Foo/Bar/ to /Foo/Bar, /Foo/Bar/?i=1 to /Foo/Bar?i=1, & avoiding redirect loop on "/" (root view)
>         RewriteEngine  on
>         RewriteRule    ^/$      /       [L]
>         RewriteRule    ^(.*)/$  $1      [R=301,L]
>         </IfModule>
> * duplicate your routing rules & conf matchmaps
> in router.php :
>     (...)
>     public function createRoutes()
>     {
>         return array(            
>             new ezcMvcRailsRoute( '/:foo/:bar', 'mkController', 'fooBar ),
>             new ezcMvcRailsRoute( '/:foo/:bar/', 'mkController', 'fooBar' ),
>         );
>     }
>     (...)
> and in lib/config.php
>     (...)
>     function createView( ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request, ezcMvcResult $result )
>     {		
>     	switch ( $routeInfo->matchedRoute )
>         {
>             case '/:foo/:bar':
>                 return new mkMuseumView( $request, $result );
>             case '/:foo/:bar/':
>                 return new mkMuseumView( $request, $result );
>         }
>     }
>     (...)
> The first one being the more short & elegant way to me, I propose that it could be added as a tip inside the existing MvcTools tutorial.
> And if I'm just misguiding myself, I humbly beg your forgiveness and silently go back to dive myself into php.net & httpd.apache.org/docs  ;-)
> Ronan

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira