首页 > 解决方案 > 为什么我的 post 方法在添加 htacess 文件后只发送 1 行表数据?

问题描述

post方法仅在我.php使用.htaccessfile.

如果我删除该.htaccess文件,它将正常运行。这是我的.htaccess文件。

DirectoryIndex index

RewriteEngine on

#remove .php extension
RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]

#add back the .php extension (ex: include 'index.php')
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [NC,L]

#add the .html extension
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.html [NC,L]

post数据应该发送所有的数据行

标签: mysqldatabase.htaccesspostmethods

解决方案


.htaccess 中缺少的部分是RewriteBase /.php,否则当您使用 *.php 时,.php 剥离的 url 将不起作用。

关于未发布的数据,请您检查表单操作并确保其中没有 php 扩展。如果表单操作具有 .php 扩展名,那么在提交时,htaccess 会重定向到不带 .php 的 url,因此数据会被忽略。

即如果你的表格是这样的

<form action="save.php" method="post">

然后将其替换为

<form action="save" method="post">


推荐阅读