douxiong2738 2013-08-14 04:14
浏览 9

更改.htaccess后未发布的数据

I am making a website in PHP, everything is working fine, but when I changed the .htaccess file post form method is not posting the data.

.htaccess file (I found this on 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

 <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>

any ideas what is wrong?

  • 写回答

1条回答 默认 最新

  • doudi8298 2013-08-14 05:39
    关注

    This rule:

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

    Is causing your POST request for view_images.php to be redirected to view_images, and thus you lose the request body (all of your POSTed data). You don't want to cause this redirect, so don't POST to the view_images.php URL. Remove the .php part so that it won't redirect:

    <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>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100