如果htaccess运行到400、401或403,请保存request_uri并重定向到自定义页面


If htaccess runs into 400, 401 or 403 save the request_uri and redirect to a custom page

我已经重定向到一个自定义错误页面。但我不想从400、401或403命中的位置获取请求的URI。我完全不懂htaccess编码。这就是我目前所拥有的:

ErrorDocument 400 'example.com/customerror.php'
ErrorDocument 401 'example.com/customerror.php'
ErrorDocument 403 'example.com/customerror.php'

现在,如果请求uri达到400、401或403,我需要以某种方式保存它,然后从自定义错误页面PHP调用它。

示例:

  1. 用户请求页面:example.com/wp-content/plugins.htaccess
  2. .htaccess阻止它
  3. .htaccess保存request_uri(/wp-content/plugins)
  4. .htaccess重定向到example.com/customerror.php customeerror.php
  5. 页面显示保存的request_uri(/wp-content/plugins)

有人能帮我做第三步和第五步吗。我已经把其他人都搞定了。我们非常感谢所有的帮助。

您可以在customerror.php上使用作为上一个请求URI的标头HTTP_REFERER将其保存为数据库或文件。