Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php CodeIgniter/输入数据丢失,$\u POST也为空_Php_.htaccess_Http_Mod Rewrite - Fatal编程技术网

Php CodeIgniter/输入数据丢失,$\u POST也为空

Php CodeIgniter/输入数据丢失,$\u POST也为空,php,.htaccess,http,mod-rewrite,Php,.htaccess,Http,Mod Rewrite,我正在将过期已久的CI 2.1更新为CI 3.1.11。到目前为止,除了丢失的表单数据外,一切正常。无论是$this->input->post('usr')还是$\u post都不保存任何值。空的 在查看了一些答案后,我认为我的htaccess可能有问题——但在其他任何情况下,它似乎都能正常工作 我在Apache2上运行PHP7.3.9修改重写已打开 这是我的访问权限 <IfModule mod_rewrite.c> <IfModule mod_negotiation.

我正在将过期已久的CI 2.1更新为CI 3.1.11。到目前为止,除了丢失的表单数据外,一切正常。无论是
$this->input->post('usr')
还是
$\u post
都不保存任何值。空的

在查看了一些答案后,我认为我的htaccess可能有问题——但在其他任何情况下,它似乎都能正常工作

我在Apache2上运行PHP7.3.9<代码>修改重写已打开

这是我的访问权限

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]


</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule> 

选项-多视图
重新启动发动机
#重写基/
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)/$/$1[L,R=301]
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]
#如果我们没有安装mod_rewrite,所有404
#可以发送到index.php,一切正常。
#提交人:ElliotHaughin
ErrorDocument 404/index.php
它可能是htaccess文件或其他文件。有什么想法吗

UPD:更让人困惑的是:vhost上这一请求的Apache日志http://esp.atlas.local 内容如下:

127.0.0.1---[2019年10月19日:23:00:42+0200]“POST/admin/HTTP/1.1”301 236
127.0.0.1--[2019年10月19日:23:00:42+0200]“GET/admin HTTP/1.1”200 4592

UPD2:混淆消除了:我将表单提交到同一个URL,这意味着它首先
向表单发布
,然后
从表单中获取
HTML视图

无论如何,我开始质疑我的道德,因为我已经尝试了所有可能的htaccess配置(甚至从我在同一台机器上运行的Lumen/Laravel项目中获得了一个),我要么什么也没有得到,要么403被禁止(这是新的,但仍然没有解决任何问题)。有进一步的想法吗?

好的,这是一个代码点火器问题,因为我的
htaccess
、表单
方法
、表单
URL
等都还可以。其他每个URL都在工作。只有$\u POST获得403

问题是csrf_令牌保护设置为true,由于不存在令牌,CI刚刚抛出403。我必须在安装目录中搜索错误字符串,以查看问题所在<代码>Duh

这是我的
htaccess
,供其他遇到类似问题的人使用(卡尔,损失了3天!)


重新启动发动机
重写基/
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^(.*)$./index.php/$1[L]

我猜其他地方已经回答了这个问题。忘记CodeIgniter片段,关注
$\u POST
是空的。。。如果中的答案都不是答案,请在问题中指出,并表明您已经处理了每一个答案…问题可能在这里
RewriteRule^(.*)/$/$1[L,R=301]
,可能您的表单操作的结尾是一个斜杠,可能是Ok的副本,谢谢您的帮助,但到目前为止还没有任何效果。偶数
php://input
为空。后面的斜杠在那里。
<IfModule mod_rewrite.c>

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

</IfModule>