Why is $ _POST empty when using [QSA] in .htaccess?

I have the following in .htaccess:

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

All works fine, but as a result, the URLs have an empty $ _POST.

I am 100% sure that this is a mod_rewrite error, not HTML or PHP, because when I change [QSA, L] to [L], it works fine. But I really need QSA.

This happens with approximately 30% of the hosting, so this may be an Apache configuration option.

+3
source share
3 answers

How about changing your rule this way. Is something changing?

 RewriteRule ^(.*)\.htm$ index.php?url=$0.htm [QSA,L] 
0
source

by default, maybe apache will not enable mod_rewrite, try entering this on the console

sudo a2enmod rewrite

select 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> 
0
source

I had exactly this problem. It runs on one server, and then not on the next. Annoying and time consuming!

After a big check using this php:

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

at the top of index.php to check which values ​​were sent from the htaccess file (and many other checks that I won’t enter!) In the end, I found that you need to specify "RewriteBase"

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

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

Hope this helps you - knowing that it would certainly help me many hours ago!

-one
source

Source: https://habr.com/ru/post/1397437/


All Articles