允许 PHP $_POST 与 htaccess
我对 htaccess 不太擅长,但对迄今为止所做的事情感到满意,直到我注意到我的 $_post 变量没有被处理,因为我的 htaccess 文件中的重写签名(SIGH)
我的目标是读取 url 并确定它是来自 php 的路径和位置,它是 $_SERVER['request_uri'] 方法,工作正常。 http://mydomain.com/ 之后的所有内容都会被分解并用作数据,因此需要 htaccess。
我的htaccess:
AddType text/x-component .htc
Options +FollowSymlinks
<Files .htaccess>
order allow,deny
deny from all
</Files>
IndexIgnore *
ErrorDocument 404 /index.php?/
<FilesMatch "(\.jpe?g|gif|png|bmp)$">
ErrorDocument 404 "File Not Found"
</FilesMatch>
RewriteEngine On
RewriteBase /
RewriteRule (.*)\.htm $1.php [L,NC]
我的php:(记住所有内容都是通过index.php解析的)
php与问题无关,因为我知道它应该有效。我一直在使用 print_r($_POST) 测试 post 变量,从表单提交时它们是空的。明显的问题是我对 htaccess 缺乏了解。
就为了这个话题。假设我的index.php 看起来像这样:
<?php
print_r($_POST);
?>
<form action="" method="post">
<input type="text" name="test">
<input type="submit" value="Test!">
</form>
这里的在线示例: www.blueaspect.com <-- 表格有效!
然后通过将 foo/ 添加到 url 末尾,您将看到加载的文件仍然是 index.php。这就是我想要的,但现在该表格不起作用。
如果有人可以提供帮助,我们将不胜感激
I'm not so good on htaccess but was happy with what I had done so far until I noticed my $_post variables were not being processed because of the rewrite signiture within my htaccess file (SIGH)
My objective was to read the url and determine it's path and location from php and it's $_SERVER['request_uri'] method, which works fine. Everything after http://mydomain.com/ gets ripped apart and used as data hence the need for htaccess.
my htaccess:
AddType text/x-component .htc
Options +FollowSymlinks
<Files .htaccess>
order allow,deny
deny from all
</Files>
IndexIgnore *
ErrorDocument 404 /index.php?/
<FilesMatch "(\.jpe?g|gif|png|bmp)$">
ErrorDocument 404 "File Not Found"
</FilesMatch>
RewriteEngine On
RewriteBase /
RewriteRule (.*)\.htm $1.php [L,NC]
my php: (baring in mind everything gets parsed through index.php)
The php is irrelevant to the problem as I know it should work. I have been testing the post variables by using print_r($_POST) and they are empty when submitted from a form. The obvious problem is down to my lack of knowledge with htaccess.
Just for this thread. lets say my index.php looked like this:
<?php
print_r($_POST);
?>
<form action="" method="post">
<input type="text" name="test">
<input type="submit" value="Test!">
</form>
online example here:
www.blueaspect.com <-- The form works!
Then by adding foo/ to the end of the url you'll see the file loaded is still index.php. Which is what I want but now the form does not work.
Please if anyone could help that would be much appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决了这个问题
fixed that problem