更新:PHP 中的 mod_rewrite 和 POST 方法问题,$_POST 始终为空
我使用 mod_rewrite 以更易读的方式显示页面地址,而不是
http://127.0.0.1/ index.php?article=contact
我得到了
当我发送表单时,所有内容都由index.php处理,所以我将表单的操作直接到当前显示的页面,但$_POST始终为空,打开 在我启动 mod_rewrite 之前,表单块看起来像这样,
<form method="post" action="http://127.0.0.1/contact">
一切都工作得很好,但现在 mod_rewrite 似乎会引起问题。
请告诉我在 PHP、Apache 配置文件中需要更改哪些内容,或者还需要做什么才能使 $_POST 与重写一起工作
这里是请求的重写规则
RewriteEngine on
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule \.(css|jpe?g|gif|png)$ - [L]
RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&va=$2 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&va=$2&vb=$3 [L]
提前感谢
Amir
Im using mod_rewrite to display adress of pages in more readable way, instead of
http://127.0.0.1/index.php?article=contact
i got
when im sending form, all is processed by index.php, so i direct action of form to currently displayed page but $_POST is always empty, opening block of form looks like this
<form method="post" action="http://127.0.0.1/contact">
before i launched mod_rewrite all was working great, but now mod_rewrite seems to cause problems.
Please tell me what to change in PHP, Apache configuration files, or what else to do to make $_POST work with rewrite endabled
Here are rewrite rules that was requested
RewriteEngine on
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule \.(css|jpe?g|gif|png)$ - [L]
RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&va=$2 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&va=$2&vb=$3 [L]
Thanks in advance
Amir
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此重写规则会执行重定向,因此浏览器将使用 GET 请求转至此地址;因此,POST 数据将始终为空。
This rewrite rule does a redirect, so the browser will instead go to this address with a GET request; the POST data will therefore always be empty.