Amir
Amir

Reputation: 13

UPDATED: mod_rewrite and POST method in PHP problem, $_POST is always empty

Im using mod_rewrite to display adress of pages in more readable way, instead of

http://127.0.0.1/index.php?article=contact

i got

http://127.0.0.1/contact

when im sending form, all is processed by index.php, so i direct action of form to currently displayed page but $_POST is always empty, opening block of form looks like this

<form method="post" action="http://127.0.0.1/contact">

before i launched mod_rewrite all was working great, but now mod_rewrite seems to cause problems.

Please tell me what to change in PHP, Apache configuration files, or what else to do to make $_POST work with rewrite endabled

Here are rewrite rules that was requested

RewriteEngine on
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule \.(css|jpe?g|gif|png)$ - [L]
RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&va=$2 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&va=$2&vb=$3 [L]

Thanks in advance

Amir

Upvotes: 1

Views: 5956

Answers (1)

El Yobo
El Yobo

Reputation: 14946

This rewrite rule does a redirect, so the browser will instead go to this address with a GET request; the POST data will therefore always be empty.

RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]

Upvotes: 2

Related Questions