Troubles with mod_rewrite and POST requests

New to mod_rewrite? This is a good place to start.

Troubles with mod_rewrite and POST requests

Postby AztEK » Thu Mar 15, 2007 1:48 am

Hi all!
I use mod_rewrite on my site, here is .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^robots.txt robots.txt [L]
RewriteRule ^index.php(.*)$ index.php$1 [L]
RewriteRule ^admin.php(.*)$ admin.php$1 [L]
RewriteRule ^(.*)$ index.php [L, QSA]
</IfModule>

It works ideal on my home server (Apache 1.3.3), but in the internet (Apache 1.3.7) I came across a problem with POST requests.

When I use form (i.e. <form action="http://server.com/guestbook/" action="post">), index.php didn't get POST variables ($_POST array).
Is it possible to use POST with mod_rewrite-redirecting?

Please, could you help me?

P.S. Sorry, if this question have already been discussing.
AztEK
 
Posts: 2
Joined: Thu Mar 15, 2007 12:20 am

Postby AztEK » Thu Mar 15, 2007 3:52 am

Bingo! :D
I removed those strings:
<IfModule mod_rewrite.c>
</IfModule>
and
DirectoryIndex index.php

Which of them causes such a bad thing I dont know, but now it works well :P
AztEK
 
Posts: 2
Joined: Thu Mar 15, 2007 12:20 am

Postby richardk » Fri Mar 16, 2007 2:20 pm

You could probably simplify that to (the first RewriteRule might not even be needed)
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^(robots.txt|index\.php.*|admin\.php.*)$ - [L]

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule . index.php [L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 0 guests