【问题标题】:periods converted to underscores句点转换为下划线
【发布时间】:2011-08-28 05:14:59
【问题描述】:

各位程序员,我在 codeigniter 控制器中有一个函数,它接受几个参数,其中一个是电子邮件地址。它被称为喜欢这样:

domain/path/mycontroller/myfunc/email@gmail.com/anotherparam  

控制器收到的是:email@gmail_com

我的 CI 配置中允许使用句点和“@”:

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-@';  

我的 .htaccess 如下:

RewriteEngine On
RewriteBase /myapp/
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /myapp/index.php?/$1 [L]

有什么想法可以解决这个问题吗?

谢谢

【问题讨论】:

    标签: .htaccess url codeigniter


    【解决方案1】:

    从 2008 年开始在 CI 论坛上找到相关帖子:

    http://codeigniter.com/forums/viewthread/94091/

    看起来有些人遇到了完全相同的问题,因此在 config.php 中调整 $config['uri_protocol'] 是解决方案。

    /*
    |--------------------------------------------------------------------------
    | URI PROTOCOL
    |--------------------------------------------------------------------------
    |
    | This item determines which server global should be used to retrieve the
    | URI string.  The default setting of "AUTO" works for most servers.
    | If your links do not seem to work, try one of the other delicious flavors:
    |
    | 'AUTO'            Default - auto detects
    | 'PATH_INFO'        Uses the PATH_INFO
    | 'QUERY_STRING'    Uses the QUERY_STRING
    | 'REQUEST_URI'        Uses the REQUEST_URI
    | 'ORIG_PATH_INFO'    Uses the ORIG_PATH_INFO
    |
    */
    $config['uri_protocol']    = "QUERY_STRING";
    

    至少有一个人报告说QUERY_STRING 值解决了他们的问题。如果这不起作用,请尝试其他 delicious flavor 设置之一。

    希望这能让您找到正确的解决方案。

    【讨论】:

    • 嘿 Wesley,看起来 REQUEST_URI 成功了。稍后我将进行更多测试,以确保此更改没有破坏其他任何内容,但看起来很有希望:) 非常感谢。感谢您的快速响应。
    【解决方案2】:

    您可以在 Base 64 中加密电子邮件地址,然后在您想使用它时取消加密:

    base64_encode($email_address);
    base64_decode($url_segment);
    

    这适用于您要通过 URL 发送的任何文本。更安全,不仅限于电子邮件地址。不过会创建一个更长的 URL。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-30
      • 2013-12-04
      • 2015-10-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-06
      • 2013-04-29
      • 1970-01-01
      相关资源
      最近更新 更多