rybo111 rybo111 - 1 year ago 55
PHP Question

mod_rewrite won't retain $_POST vars on Apache 2.4

is not passing my $_POST variables and GoDaddy have assured me it is because I need to alter my setup for Apache 2.4.

Here is my code:


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]


$q = explode("/", $_SERVER['REQUEST_URI']);
if ($q[1] != "") {
switch($q[1]) {
case "test":


if (isset($_POST["submitButton"])) {
echo "Submitted";
} else {
echo "Not submitted";
<form method="post">
<input type="submit" name="submitButton">

When submitting via /test, it shows "Not submitted".

When submitting via /test.php, it shows "Submitted".

I have tried this exact setup on another host and it works fine.

What needs changing in order for it to work?

Answer Source

The reason this happens is because GoDaddy's settings point the user to missing.html when the URL isn't a recognised file.

The fix is to ignore GoDaddy's .htaccess file by adding Options -Multiviews to your own .htaccess file.