3

I've got the following in .htaccess:

RewriteCond %{REQUEST_URI} !app/index\.php$
RewriteRule ^(.*\.htm)$ index.php?url=$0 [QSA,L]

Everyting works great but result URLs have empty $_POST.

I'm 100% sure that it's mod_rewrite bug, not HTML or PHP because when I change [QSA,L] to [L] it works great. But I really need QSA.

It happens at about 30% hostings so this may be some Apache config option.

luchaninov
  • 6,792
  • 6
  • 60
  • 75
  • 3
    Can you check to see if anything is available in $_REQUEST (which includes $_GET and $_POST) - I'm curious to see if your $_POST values are transforming into $_GET values... – Fenton Jan 19 '11 at 08:37
  • Yes, I've checked. $_REQUEST is filled with $_GET values only – luchaninov Jan 19 '11 at 20:53
  • the thing which puzzled me a few times in the query is the $0 instead of $1 – karlcow Jan 27 '11 at 00:03

3 Answers3

0

What about modifying your rule in this way. Does it change anything?

RewriteRule ^(.*)\.htm$ index.php?url=$0.htm [QSA,L]
karlcow
  • 6,977
  • 4
  • 38
  • 72
  • strange. Is there a variation between servers depending on the server version? Or does it happen randomly? – karlcow Jan 27 '11 at 12:20
-1

by default,.. maybe apache not enable mod_rewrite, try type this on your console

sudo a2enmod rewrite

sample my .htaccess

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
  ErrorDocument 404 /index.php
</IfModule>
bayoz
  • 99
  • 1
  • 11
-1

I had exactly this issue. It works on one server then not the next. Annoying and time consuming to say the least!

After a lot of checking using this php:

foreach ($_REQUEST AS $key => $value) echo $value."<br>";

at the top of the index.php to check what values were being sent from the htaccess file, (and many other checks I will not go into!) I eventually found you need to specify "RewriteBase"

Adding RewriteBase / to the top of the htaccess file made it work on the all the servers I tried.

(also, remember to set to: RewriteBase /folder-where-file-is/ where "folder-where-file-is" is the location of the index.php file if in a sub-folder)

Hope it helps you - knowing this would certainly have helped me many many hours ago!