1

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]

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>

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

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

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

Community
  • 1
  • 1
user3244721
  • 714
  • 2
  • 11
  • 29

1 Answers1

1

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

RewriteCond %{REQUEST_METHOD} POST
RewriteRule ^ - [L]
anubhava
  • 761,203
  • 64
  • 569
  • 643