1

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

Amir
  • 13
  • 1
  • 4
  • You should add your rewrite here too. There are different ways to rewrite, some of which may cause issues. Although, I'm most concerned about the fact that code is actually calling index.php... and if it is just a simple templating system, I'm not sure where your form processing would happen. – John Green May 21 '11 at 03:18
  • What are your rewrite rules? You most likely need to add a capture group for the parameters. – Erik Nedwidek May 21 '11 at 03:18
  • Your probably have some logic error in your rewrite, show us your rewrite rules – Ibu May 21 '11 at 03:43

1 Answers1

2

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]
El Yobo
  • 14,823
  • 5
  • 60
  • 78
  • thank you, reomoving that seems to fix the problem, can u suggest me what i should do if redirect like that (or similar) would be required? is there any way to redirect POST data as well? – Amir May 21 '11 at 13:43
  • The rules that you have underneath rewrite the same request (e.g. those without the HTTP 301 code). – El Yobo May 21 '11 at 13:53