开发者

Why doesn't a URL with two hyphens ( in one segment ) match a Route in my Route Table?

I'm trying to resolve this URL Route:

Route articlesByCategory = new Route("articles/c{cid}-{category}", new Handler);

However, it seems like the following url won't resolv开发者_开发问答e to this route:

// doesn't work
www.site.com/articles/c24-this-is-the-category-title

// This works
www.site.com/articles/c24-category

I assume it has to do with the dashes in the title, but can anyone tell me why this works this way?

Is there a way to allow dashes in the title for a URL route like this?


Which hyphen is the delimiter?

Server doesn't know which hyphen in your URL is delimiting cid from category. That's why it can't work. You could solve this by using something else than dashes in your category value. Or write a custom Route class that will be more flexible with definitions.

This answer on Stackoverflow may help you, because it can easily be used in your case...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜