Htaccess Codeigniter问题
我在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
是的,这在 CI 中有效,
如果在 CI 中禁用它们,您仍然可以访问查询字符串,请尝试此代码
请尝试从 URL 中删除 index.php,请使用此代码
如果您在子目录中有 CI 应用程序,
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
if you have CI app in sub directories use this
您可以尝试的一件事是在您的基本目录中放置一个名为 paypalcallback.php 的普通 php 文件或使用以下代码的类似内容:
它基本上读取查询字符串并转换为 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:
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.
您需要在 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']
相关:
CodeIgniter PHP 框架 - 需要获取查询字符串
< a href="https://stackoverflow.com/questions/2043070/enabling-get-in-codeigniter">在 codeigniter 中启用 $_GET
Related:
CodeIgniter PHP Framework - Need to get query string
Enabling $_GET in codeigniter
首先,谢谢大家,我的朋友们,
我尽力关注你们所有的帖子。最后,我找到了适合我的情况的正确方法,非常简单。
我像这样更改 htacces 文件:
你看,我插入了“?”前 '/'。它将接受我的 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:
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,
在谷歌搜索几个小时后,以下步骤对我有用:
在 application/config/config.php 中我使用了此更改
在 .htaccess
在/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 :
In application/config/config.php i used this change
In .htaccess
In /system/libraries/URI.php
That's it. I took one of these solution from http://dragffy.com/blog/posts/codeigniter-17-the-uri-you-submitted-has-disallowed-characters