此问题在某种程度上与我的$p$pvious问题。使用的伎俩 $ _ SERVER ['REDIRECT_QUERY_STRING']
似乎只对 $工作_ GET
变量。
嗯,我有一个的index.php
文件,该文件处理所有的 404重定向
。如果存在一个网页,其中犯规,用户的请求,也就是说,一个 pple.php?项目= 23
,然后用 $ _ SERVER ['REDIRECT_QUERY_STRING']
我能获得 $ _ GET
变量项目= 23
,但如果变量不 $ _ GET
,但 $ _ POST
然后 $ _ SERVER ['REDIRECT_QUERY_STRING']
不起作用。我怎样才能 $ _ POST
变量时,我重定向到的index.php
使用以下的.htaccess设置
ErrorDocument的404的index.php
解决方案检查答案在这里:的 http://www.brainonfire.net/blog/apache-pitfall-errordocument-post/
我用这个解决了我的问题。
或把它放进你的.htaccess文件:
RewriteEngine叙述上 的RewriteBase / 的RewriteCond%{} REQUEST_FILENAME!-f 的RewriteCond%{} REQUEST_FILENAME!-d 重写规则。 /yourErrorDocument.php [L]
This question is somewhat related to my previous question. The trick of using $_SERVER['REDIRECT_QUERY_STRING']
seems to work only for $_GET
variables.
Well, I've an index.php
file which handles all the 404 redirects
. If a user requests for a page which doesnt exist, say, apple.php?item=23
, then using $_SERVER['REDIRECT_QUERY_STRING']
i can get the $_GET
variable item=23
, but if the variable is not $_GET
but $_POST
then $_SERVER['REDIRECT_QUERY_STRING']
doesn't work. How can i get $_POST
variable when i redirect it to index.php
using the following .htaccess setting
ErrorDocument 404 /index.php
解决方案
Check answer here : http://www.brainonfire.net/blog/apache-pitfall-errordocument-post/
I solved my problem using this.
OR put this in your .htaccess file :
RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /yourErrorDocument.php [L]