简体   繁体   English

使用mod_rewrite时捕获404s

[英]Capturing 404s when using mod_rewrite

I'm trying to track down some unexpected 404s in a hybrid WordPress/custom code site. 我正在尝试在混合WordPress /自定义代码站点中追踪一些意外的404。 Since the 404s are redirected I'm not seeing the original request in the access_logs. 由于404s被重定向,我没有在access_logs中看到原始请求。

What is a good way to track these given WordPress' rewrite_rules are in the mix? 跟踪这些给定的WordPress'rewrite_rules的好方法是什么?

.htaccess is just WP .htaccess只是WP

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

If you're happy to install a plugin, something like the Redirection plugin might help (disclaimer - I've never used it). 如果你很乐意安装一个插件,像Redirection插件这样的东西可能会有所帮助(免责声明 - 我从未使用它)。

Failing that, you could try hooking the template_redirect action and logging the $_SERVER info if is_404() returns true. 如果失败,您可以尝试挂钩template_redirect操作并记录$_SERVER信息,如果is_404()返回true。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM