Htaccess Codeigniter problem


Htaccess Codeigniter problem

我在项目中使用了使用 Codeigniter 框架的 htaccess:

目录索引索引.php

RewriteEngine on
RewriteCond $1 !^(index'.php|assets|robots'.txt|favicon'.ico) [NC]
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.*)$ ./index.php/$1 [NC,L,QSA]

我的问题是,当我调用PayPal服务时,PayPal响应我一个 GET 网址,如下所示:http://xxx.xx.com/myproject/paypalCallback?tx=32J30607S6157364F&st=Pending&amt=85.00&cc=SGD&cm=&item_number=

我收到未找到 404 页面。Htaccess 不接受 GET URL: ?tx=32J30607S6...我确定这是在本地工作,但不是现场工作

如果可以,请帮助我。谢谢

是的,这在 CI 中有效

如果在 CI 中禁用查询字符串,您仍然可以访问查询字符串,请尝试此代码

从网址中删除索引.php

RewriteEngine On
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

如果您的子目录中有 CI 应用程序,请使用此

RewriteBase /f2f/f2fweb

您可以尝试的一件事是将一个名为paypalcallback的纯PHP文件放在基目录中.php或者使用以下代码进行类似的操作:

$tx  = $_GET['tx'];
$st  = $_GET['st'];
$amt = $_GET['amt'];
... etc ...
header("location:/myproject/papalCallback/$tx/$st/$amt");
exit;

它基本上读取查询字符串并转换为 url 段。 通常,这比弄乱查询字符串和创建花哨的重写规则更容易。 我用它来链接到 CKeditor 中的图像管理器,因为它在回调中需要一个查询字符串变量。

我想这在很大程度上取决于 http 标头代码是否重要。

您需要

在应用程序/配置/配置中启用查询字符串.php或在$config['permitted_uri_chars"中启用"?"字符]

相关:

CodeIgniter PHP Framework - 需要获取查询字符串

在编码点火器中启用 $_GET

首先,感谢你们所有人,我的朋友们,

我尝试关注您的所有帖子。最后,我为我的案件找到了正确的方法,这很简单。我像这样更改 htacces 文件:

RewriteRule ^(.*)$ ./index.php?/$1 [NC,L,QSA]

你看,我在"/"之前插入"?"。它将接受我的网址..paypalCallback/?tx=123213.

这是工作。也许我很幸运^ ^

无论如何,感谢您的帮助

干杯

谷歌搜索几个小时后,以下步骤对我有用:

  1. 在应用程序/配置/配置中.php我使用了这个更改

      $config['enable_query_strings'] = TRUE;
      $config['index_page'] = "";
    
  2. 在 .htaccess 中

     RewriteEngine on
     RewriteCond $1 !^(index'.php|application|media|images|robots'.txt)
     RewriteRule ^(.*)$ /index.php?/$1 [L]
    
  3. 在/system/libraries/URI 中

    .php
     Replace
        if ( ! preg_match("|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i", $str))
     With
        if ( ! preg_match("|^[".str_replace('''-', '-', preg_quote ($this->config->item('permitted_uri_chars')))."]+$|i", $str))
    

就是这样。我从 http://dragffy.com/blog/posts/codeigniter-17-the-uri-you-submitted-has-disallowed-characters 那里获得了其中一种解决方案