I just stumbled across the opposite problem... :)
I had routes set up like this:
Router::connect(
'/places/:location/:category/*',
array('controller' => 'places', 'action' => 'index'),
array('location' => '\D+', 'category' => '\D+')
);
So a URL like /places/new_york/shopping would be handled by the
PlacesController::index() method, with the parameters being passed as
$this->params => array(
['location'] => 'new_york',
['category'] => 'shopping'
)
Attaching a trailing slash to the URL would make it fail though, like /
places/new_york/shopping/ .
I just figured out that the category ended up in the controller as
['category'] => 'shopping/'.
This is because when defining the route, I set the rule for category a
bit too loose as '\D+', meaning "one or more non-numeric character",
which caught the slash as well.
The point being, if you supply the right regular expression when
specifying a route, you can catch parameters even with slashes in
them. Whether that'll work reliably for you I don't know, but it might
be something to look into.
The nicer way of course is to have a "sluggable" alternative handy for
your categories/names/ids.
On 10 Sep 2008, at 10:04, Gustavo Carreno wrote:
>
> Hey friend,
>
> I've had this discussion with a fellow baker that was trying this and
> we got to the conclusion that it's not possible to use urlencode().
> The reason is that the urlencoded string will be translated and feed
> to the internal url var( mod_rewrite thing ) and it will have the
> translated slashes.
>
> The only way to go around is to either base64encode the string taking
> care to reverse it once inside the action.
> Another way is to switch the slashes to some other char and then
> reverse it once on the action.
>
> Cheers,
> Gus
>
> 2008/9/8 starkey <[EMAIL PROTECTED]>:
>>
>> Hello,
>>
>> I am trying to create a URL that contains unnamed parameters that
>> could be strings with forward slashes. I've looked around and saw
>> that it is recommended to use urlencode(), which I tried. The URL
>> ends up looking like this:
>>
>> /view/Migration%2FTransportation
>>
>> however, I still get a 404. Is there something I need to do in
>> routing to get this to work?
>>
>> Thank a lot!
>> S
>>>
>>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---