htaccess的ErrorDocument的404和传递的URL路径 [英] htaccess errordocument 404 and pass url to path

查看:510
本文介绍了htaccess的ErrorDocument的404和传递的URL路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何通过404'd URL来利用我404.html页的.htaccess

How can I pass the 404'd URL to my 404.html page using .htaccess

例如,如果我访问一个无效的页: /用户/ 123

For example, if I visit an invalid page: /user/123

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
ErrorDocument 404 /?404.php?error_path={???}
                                         ^
=========================================^ 

从而产生了404重定向到 /404.php?error_path=/user/123

推荐答案

的ErrorDocument 不是的mod_rewrite的一部分,是无效的。难道这是你想找的?

ErrorDocument is not part of mod_rewrite and that is invalid. Is this what your looking for?

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Rewriterule ^(.*) /404.php?error_path=$1 [R=301,L]

这篇关于htaccess的ErrorDocument的404和传递的URL路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆