更改.htaccess后未发布数据


data not posting after changing the .htaccess

我正在用PHP制作一个网站,一切都很好,但当我更改.htaccess文件后表单方法时,并没有发布数据。

.htaccess文件(我在stackoverflow.com上找到这个)

#Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## don't touch /forum URIs
RewriteRule ^forums/ - [L,NC]
## hide .php extension snippet
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}'s([^.]+)'.php [NC]
RewriteRule ^ %1 [R,L]
# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]

形成

 <form method="post" id="form" action="view_images.php">
    <input type="text" name="img" value="images/1.jpg" id="img_name" />
    <input type="submit" id="submit" value="submit" />
</form>

有什么想法吗?

此规则:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}'s([^.]+)'.php [NC]
RewriteRule ^ %1 [R,L]

导致您对view_images.php的POST请求重定向到view_images,从而丢失请求主体(所有POST数据)。您不希望导致此重定向,所以不要POST到view_images.php URL。删除.php部分,使其不会重定向:

<form method="post" id="form" action="view_images">
    <input type="text" name="img" value="images/1.jpg" id="img_name" />
    <input type="submit" id="submit" value="submit" />
</form>