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

点点圈 提交于 2019-12-06 01:47:29

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

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

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>

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!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!