Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/245.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用.htaccess文件扩展名删除程序代码时,网站表单不带任何值_Php_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Php 使用.htaccess文件扩展名删除程序代码时,网站表单不带任何值

Php 使用.htaccess文件扩展名删除程序代码时,网站表单不带任何值,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我在HTACCESS文件中有这段代码,它删除了.php文件扩展名,可以很好地工作。它还允许加载页面而不需要扩展名 # For security reasons, Option followsymlinks cannot be overridden. #Options +FollowSymLinks -MultiViews Options +SymLinksIfOwnerMatch -MultiViews # Turn mod_rewrite on RewriteEngine On Rewrite

我在HTACCESS文件中有这段代码,它删除了.php文件扩展名,可以很好地工作。它还允许加载页面而不需要扩展名

# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks -MultiViews
Options +SymLinksIfOwnerMatch -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]

## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
它工作得很好。问题是当我使用这个代码时

<form action="test.php" method="post" id="myform" name="myform">
<input type="text"  name="username">
<input type="submit" value="login">
</form>

在test.php
echo$_请求['username']上为空/空

我试图从表单操作中删除.php,但我无法从网站中使用的所有文件中删除.php


对于重复标记:我读了这篇文章,但我的问题不同。对我来说,表单提交但不带任何值。

RewriteBase
行下方插入此规则,以避免重定向POST请求:

RewriteCond %{REQUEST_METHOD} POST
RewriteRule ^ - [L]

我不想浪费时间把这个标记为答案节省我的时间谢谢