Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.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
Regex codeigniter中的URL路由问题_Regex_Codeigniter_Url Routing - Fatal编程技术网

Regex codeigniter中的URL路由问题

Regex codeigniter中的URL路由问题,regex,codeigniter,url-routing,Regex,Codeigniter,Url Routing,我正在尝试使用codeigniter URL路由来路由URL。 我想重定向一个url,如 /用户/编辑?发送电子邮件至用户控制器/编辑电子邮件 /用户/edit?用户控制器的密码/editpassword 我尝试在配置文件夹的routes.php中使用以下行 $route["users/edit?(email|password)"] = "userController/edit$1"; 这将显示未找到的页面。我猜是吧?正被视为正则表达式字符。我试图逃避,但也没用 我不想将配置设置uri_协

我正在尝试使用codeigniter URL路由来路由URL。 我想重定向一个url,如

  • /用户/编辑?发送电子邮件至用户控制器/编辑电子邮件
  • /用户/edit?用户控制器的密码/editpassword
我尝试在配置文件夹的routes.php中使用以下行

$route["users/edit?(email|password)"] = "userController/edit$1";
这将显示未找到的页面。我猜是吧?正被视为正则表达式字符。我试图逃避,但也没用

我不想将配置设置uri_协议设置为PATH_INFO或QUERY_STRING,因为这只是我想要设置的一个漂亮的URL,而不是向操作传递任何内容

有人能帮我吗


关于你应该像这样避开
,它应该能工作。(未测试)

以后编辑

这将按预期工作:

$route["users/edit(email|password)?"] = "userController/edit$1";
userController
如下所示

<?php

class UserController extends Controller {

    function edit()
    {
        echo "general edit";
    }

    function editemail()
    {
        echo "edit email!";
    }

    function editpassword()
    {
        echo "edit password";
    }
}

@Bogdan-已经尝试过了,但失败了。不知道这是否与允许的URL字符有关,它没有?在它的任何地方。但它并没有显示“URI有不允许的字符”消息。它显示“找不到页面”。@Bogdan-我不明白。您在以后的编辑中编写的内容,不应该适用于像
用户/editmail
用户/editpassword
用户/edit
这样的URL吗?URL中的问号在哪里?我在
users/edit?password
@Bogdan中遇到问题-您建议的解决方案要求我更改URL规范。我很好奇,在CI中是否可以不更改它就完成它。您必须找到另一种方法,因为
不起作用。我查看了
~/libraries/Router.php
\u validate\u request()。您应该尝试使用
/
或任何其他方法,如我上面描述的方法
<?php

class UserController extends Controller {

    function edit()
    {
        echo "general edit";
    }

    function editemail()
    {
        echo "edit email!";
    }

    function editpassword()
    {
        echo "edit password";
    }
}