Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 仅为一个控制器更改UrlManager_Php_Url_Yii_Url Rewriting_Url Routing - Fatal编程技术网

Php 仅为一个控制器更改UrlManager

Php 仅为一个控制器更改UrlManager,php,url,yii,url-rewriting,url-routing,Php,Url,Yii,Url Rewriting,Url Routing,我的Yii 1.x应用程序已将UrlManager配置为生成/使用URL,如content/show.html: 'urlManager'=>array ( 'class'=>'UrlManager', 'showScriptName'=>false, 'urlFormat'=>'path', 'urlSuffix'=>'.html', 'rules'=>array ( '<controll

我的Yii 1.x应用程序已将UrlManager配置为生成/使用URL,如
content/show.html

'urlManager'=>array
(
    'class'=>'UrlManager',
    'showScriptName'=>false,
    'urlFormat'=>'path',
    'urlSuffix'=>'.html',
    'rules'=>array
    (
        '<controller:\w+>/<id:\d+>'=>'<controller>/view',
        '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
        '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
        '<controller:[\w\-]+>/<action:[\w\-]+>'=>'<controller>/<action>'
    )
),
'urlManager'=>数组
(
'class'=>'UrlManager',
'showScriptName'=>false,
“urlFormat'=>“路径”,
'urlSuffix'=>'.html',
'规则'=>数组
(
“/”=>“/视图”,
“/,它允许我使用路由的连字号,即
一个指向标准
anActionName
的操作名

我希望保持这种方式,但我希望扩展它,因此对于一个控制器(用于AJAX调用),它不使用
urlSuffix
,而是以这种格式生成/使用URL:
AJAX/get published files


因为我对正则表达式是一个完全的新手(几乎一无所知),所以在询问之前,我没有进行过太多的研究,因为我甚至不知道在哪里进行搜索,以及实际搜索的内容。

您可以将后缀作为模式的一部分,而不是全局配置

例如:

    'ajax/<action:\w+>'=>'ajax/<action>',
    '<controller:\w+>/<id:\d+>.html'=>'<controller>/view',
    '<controller:\w+>/<action:\w+>.html'=>'<controller>/<action>',
    '<controller:\w+>/<action:\w+>/<id:\d+>.html'=>'<controller>/<action>',
    '<controller:[\w\-]+>/<action:[\w\-]+>.html'=>'<controller>/<action>',
“ajax/”=>“ajax/”,
“/.html”=>“/view”,
“/.html”=>“/”,
'//.html'=>'/',
“/.html”=>“/”,

ofc删除urlManager配置的后缀部分

我试图找到允许您使用多个后缀的插件,但规则会根据后缀/前缀变成数组中的一个数组,但对于一个控制器来说,这似乎有点过头了