0

I'm trying to create a dynamic url pattern for the following url:

http://domain.com/content/pagetitle

This is what I have added in the url.rules:

'content/<page:.*?>' => 'cms/default/home',

this works fine for /content/pagetitle.html but not for /content/pagetitle while my url suffix is empty. Does anyone know what I'm doing wrong?

4

3 回答 3

1

您的问题也可能是,如果在命名 group 之外,.正则表达式“任何字符”字符会转义。

<controller:[a-zA-Z]>/(.*)

变成

<controller:[a-zA-Z]>/(\.*)
//                     ^ It escaped it for us even though we didn't want it

解决方案是简单地为它组:

<controller:[a-zA-Z]>/<wildcard:.*>
于 2015-03-03T14:07:55.353 回答
1

在这种情况下,您不需要通配符:

'content/<page>' => 'cms/default/home',
于 2013-04-23T06:01:34.273 回答
0

不确定为什么要添加 .*?那里...

下面的例子应该工作

'content/<page:.+>' => 'cms/default/home',
于 2013-04-22T13:13:12.880 回答