This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » legacy support » symfony 1.0 » Routing with default values exposes two URLs.
Routing with default values exposes two URLs. [message #91766] Tue, 19 January 2010 14:15 Go to next message
joshd  is currently offline joshd
Messages: 5
Registered: February 2007
Junior Member
I am defining routes with default values and requirements in my routing.yml file, like so:

bookList:
  url:                                      /books/:page
  param:
    module:                                 book
    action:                                 list
    page:                                   1
  requirements:
    page:                                   \d+


This works, I am able to link to the appropriate page, with 1 being the default.

//Outputs link to /books/1.html
echo link_to('@bookList'); 
//Outputs link to /books/2.html
echo link_to('@bookList?page=2'); 


However if I request the URL /books.html this still matches the bookList route even though it is missing an integer and trailing slash.

I don't want the same page accessible on two different URLs. Unfortunately I can't change the action code to check the incoming page attribute for reasons I won't go into. I could omit the default value, and rewrite all my links but this is also problematic as it's a large code base. Is there any way to detect the missing page number and have the URL not match the route in a sane manner?
Re: Routing with default values exposes two URLs. [message #102838 is a reply to message #91766 ] Wed, 21 July 2010 06:23 Go to previous message
tejasparmarc  is currently offline tejasparmarc
Messages: 6
Registered: July 2010
Junior Member
hi, josh

i think your code is 100% ok

However try this,

bookList:
url: /books/:page
param: { module: book, action: list, page: 1 }
requirements: { page: \d+ }

And dont forget to do symfony cc

[Updated on: Wed, 21 July 2010 06:24]

Previous Topic:can't get raw output in symfony 1.0.21
Next Topic:redirect errorHandler
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software