You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CodeIgniter搜索邮箱时出现「The URI you submitted has disallowed characters」错误求助

Fixing "The URI you submitted has disallowed characters" in CodeIgniter (Email Search Specific)

Hey there! Let's tackle this URI character issue you're hitting when searching by email—super common once you dig into how CodeIgniter handles URI rules, so let's break down the fixes that usually resolve this:

1. Double-Check Your permitted_uri_chars Configuration

First, head to your application/config/config.php (for CodeIgniter 3) or app/Config/App.php (for CodeIgniter 4) and look for the setting that controls allowed URI characters.

For CodeIgniter 3, it's:

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

For CodeIgniter 4, it's:

public $allowedURIChars = 'a-z 0-9~%.:_\-';

The problem here is that email addresses include the @ symbol, which isn't in the default allowed list. Update the line to add @ to the allowed characters:

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

// CodeIgniter 4
public $allowedURIChars = 'a-z 0-9~%.:_\-@';

Pro tip: Don't set this to an empty string (it disables all checks and is a security risk)—only add the specific characters you need.

2. Verify How You're Passing the Email Parameter

If you've already updated the above setting and still see the error, check how your search form is sending the email:

  • If you're putting the email directly in the URI path (e.g., yourdomain.com/search/email/john@doe.com): The fix above should work, but make sure you didn't miss adding @ or have a typo in the config line.
  • If you're using query strings (e.g., yourdomain.com/search?email=john@doe.com): You need to enable query string support in CodeIgniter. In config.php (CI3) or App.php (CI4):
    // CodeIgniter 3
    $config['enable_query_strings'] = TRUE;
    $config['allow_get_array'] = TRUE; // This is usually default, but double-check
    
    // CodeIgniter 4
    public $enableQueryStrings = true;
    
    Query strings bypass the URI segment character checks, so this is a solid alternative if you don't want to modify the allowed URI chars.

3. Check for Accidental URI Redirection

Sometimes, even if you use POST for your form, a redirect might be pushing the email into the URI path (e.g., after form submission). If that's the case, either adjust the redirect to not include the email in the URI, or ensure the permitted_uri_chars setting includes all necessary email characters.

4. Clear Any Cached Configs

If you're using CodeIgniter's caching or a server-side cache (like OPcache), clear those caches after modifying the config file—old settings can stick around and prevent your changes from taking effect.


内容的提问来源于stack exchange,提问作者Marium pakistan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:18:14