Htaccess Codeigniter问题

发布于 2024-11-07 12:53:55 字数 772 浏览 0 评论 0原文

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

DirectoryIndex index.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 url,如下所示: http ://xxx.xx.com/myproject/paypalCallback?tx=32J30607S6157364F&st=Pending&amt=85.00&cc=SGD&cm=&item_number=

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

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

I used an htaccess in my project that use Codeigniter framework:

DirectoryIndex index.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]

My problem is, when i call a paypal service, Paypal response for me an GET url, like that:
http://xxx.xx.com/myproject/paypalCallback?tx=32J30607S6157364F&st=Pending&amt=85.00&cc=SGD&cm=&item_number=

I receive a 404 page not found. Htaccess doesn't accept GET URL: ?tx=32J30607S6...
I sure it's work on local, but not on live side

If you can, please help me.
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

吻安 2024-11-14 12:53:55

是的,这在 CI 中有效,

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

请尝试从 URL 中删除 index.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

yes this works in CI

you can still access query string if they are disable in CI, try this code

To remove index.php from URL

RewriteEngine On

RewriteCond %{REQUEST_URI} ^system.*

RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L]

if you have CI app in sub directories use this

RewriteBase /f2f/f2fweb
忆沫 2024-11-14 12:53:55

您可以尝试的一件事是在您的基本目录中放置一个名为 paypalcallback.php 的普通 php 文件或使用以下代码的类似内容:

$tx  = $_GET['tx'];
$st  = $_GET['st'];
$amt = $_GET['amt'];
... etc ...

header("location:/myproject/papalCallback/$tx/$st/$amt");
exit;

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

我想这大部分取决于 http 标头代码是否重要。

One thing that may work that you can try is putting a plain php file in your base directory called paypalcallback.php or something along those lines with the following code:

$tx  = $_GET['tx'];
$st  = $_GET['st'];
$amt = $_GET['amt'];
... etc ...

header("location:/myproject/papalCallback/$tx/$st/$amt");
exit;

It basically reads query strings and converts to url segments. Generally it's easier than messing with the query strings and creating fancy rewrite rules. I use it for linking to a image manager in CKeditor, because it requires a querystring variable in the callback.

I guess most of this would depend on whether or not the http header code matters.

如果没有 2024-11-14 12:53:55

您需要在 application/config/config.php 中启用查询字符串或启用“?” $config['permissed_uri_chars'] 中的字符

You need to enable query string in application/config/config.php or enabled '?' character in $config['permitted_uri_chars']

衣神在巴黎 2024-11-14 12:53:55

相关:

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

< a href="https://stackoverflow.com/questions/2043070/enabling-get-in-codeigniter">在 codeigniter 中启用 $_GET

煮茶煮酒煮时光 2024-11-14 12:53:55

首先,谢谢大家,我的朋友们,

我尽力关注你们所有的帖子。最后,我找到了适合我的情况的正确方法,非常简单。
我像这样更改 htacces 文件:

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

你看,我插入了“?”前 '/'。它将接受我的 URL ..paypalCallback/?tx=123213。

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

无论如何,谢谢你的帮助

干杯,

First, thanks all of you, my friends,

I try to follow all your posts. And finaly, I found the correct way for my case, it's very simple.
I change htacces file like this:

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

You see, i insert '?' before '/'. It's will accept my URL ..paypalCallback/?tx=123213.

It's work. May be I'm lucky ^ ^

Anyway, thanks for your help

Cheers,

顾挽 2024-11-14 12:53:55

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

  1. 在 application/config/config.php 中我使用了此更改

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

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

    <前><代码> 替换

    if ( ! preg_match("|^[".preg_quote($this->config->item('permissed_uri_chars'))."]+$|i", $str))

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

就是这样。我从 http: //dragffy.com/blog/posts/codeigniter-17-the-uri-you-subscribed-has-disallowed-characters

The following steps worked for me after googling for few hours :

  1. In application/config/config.php i used this change

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

     RewriteEngine on
     RewriteCond $1 !^(index\.php|application|media|images|robots\.txt)
     RewriteRule ^(.*)$ /index.php?/$1 [L]
    
  3. In /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))
    

That's it. I took one of these solution from http://dragffy.com/blog/posts/codeigniter-17-the-uri-you-submitted-has-disallowed-characters

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文