post
方法在我使用 .htaccess
文件删除扩展文件 (.php
) 后仅发送表格的 1 行。
如果我删除 .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
数据应发送所有数据行
最佳答案
.htaccess 中缺少的一个部分是 RewriteBase /
,否则当你使用 *.php 时 .php 剥离的 url 将不起作用。
关于未发布的数据,请检查表单操作并确保其中没有php扩展。如果表单操作具有 .php 扩展名,则在提交时,htaccess 重定向到不带 .php 的 url,因此数据将被忽略。
即如果你的表格是这样的
<强> <form action="save.php" method="post">
然后将其替换为
<强> <form action="save" method="post">
关于mysql - 为什么我添加 htacess 文件后我的 post 方法只发送 1 行表数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57852132/