Php 使用.htaccess文件扩展名删除程序代码时,网站表单不带任何值
我在HTACCESS文件中有这段代码,它删除了.php文件扩展名,可以很好地工作。它还允许加载页面而不需要扩展名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
# 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.phpecho$_请求['username']上代码>为空/空
我试图从表单操作中删除.php,但我无法从网站中使用的所有文件中删除.php
对于重复标记:我读了这篇文章,但我的问题不同。对我来说,表单提交但不带任何值。在RewriteBase
行下方插入此规则,以避免重定向POST请求:
RewriteCond %{REQUEST_METHOD} POST
RewriteRule ^ - [L]
我不想浪费时间把这个标记为答案节省我的时间谢谢