网站形式不携带任何值时的.htaccess文件扩展名卸妆code用于 [英] Website Form do not carry any value when .htaccess File Extension Remover Code is Used

查看:158
本文介绍了网站形式不携带任何值时的.htaccess文件扩展名卸妆code用于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个code中的.htaccess文件,它工作得很好,因为它删除PHP文件extension.It也允许页面未扩展加载。

I have this code in HTACCESS file and it works fine as it remove .php file extension.It also allows page to load without extension.

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

它的工作原理罚款。问题是,当我使用code

It works fine.The issue is when i use this code

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

在test.php的回声$ _REQUEST [用户名]; 是空/空

On test.php echo $_REQUEST['username']; is empty/null.

我试图从表单操作删除的.php然后worked.But我不能在网站上使用的所有文件删除的.php。

I tried to remove .php from form action then it worked.But i can not remove .php from all files used in website.

有关重复的标记:我读这<一href="http://stackoverflow.com/questions/20711870/htaccess-file-extension-remover-$c$c-breaks-website-form">post但我的问题是different.With我,形式submites但不携带价值。

For Duplicate markers:I read this post but my question is different.With me,form submites but carrying no values.

推荐答案

插入此规则仅低于的RewriteBase 行来避免重定向POST请求:

Insert this rule just below RewriteBase line to avoid redirecting POST requests:

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

这篇关于网站形式不携带任何值时的.htaccess文件扩展名卸妆code用于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆