Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 404重定向和保留查询字符串_.htaccess_Redirect_Http Status Code 404 - Fatal编程技术网

.htaccess 404重定向和保留查询字符串

.htaccess 404重定向和保留查询字符串,.htaccess,redirect,http-status-code-404,.htaccess,Redirect,Http Status Code 404,我尝试将网站上的所有http查询(如“”(生成404错误)重定向到“”(以将abcd请求保留在数据库中) 我试图找到一种使用.htaccess文件的方法,但没有任何效果:( 我试过这样的方法: ErrorDocument 404 http://www.example.com/error.php?e=$1 我知道我必须做一些重写cond和RewriteRule的工作,但我不知道如何正确使用is 谢谢您应该删除http://...避免完全重定向,即: ErrorDocument 403 /erro

我尝试将网站上的所有http查询(如“”(生成404错误)重定向到“”(以将abcd请求保留在数据库中)

我试图找到一种使用.htaccess文件的方法,但没有任何效果:(

我试过这样的方法:

ErrorDocument 404 http://www.example.com/error.php?e=$1
我知道我必须做一些重写cond和RewriteRule的工作,但我不知道如何正确使用is


谢谢

您应该删除
http://...
避免完全重定向,即:

ErrorDocument 403 /error.php?e=403
ErrorDocument 404 /error.php?e=404
现在,您可以使用以下方法获取原始的404导致URI:

$_SERVER["REQUEST_URI"]=/abcd
$\u GET['e']
将为您提供代码
404
403
等,以防您需要基于此的逻辑