【发布时间】:2016-08-17 04:42:28
【问题描述】:
我在 Wordpress 之外使用了几个文件夹,如果文件不存在,我想显示一个自定义 404 文件(不是 404 标准 Wordpress 页面)。在这些文件夹中,我有一个 .htaccess,只有 2 行“RewriteOptions Inherit”和“ErrorDocument 404 /err/404.php”。它工作正常,但问题是有时某些广告横幅未在其脚本中使用其域,并且我的日志中有错误。
[the_date] [error] [client IP] File does not exist: /home/admin/web/my_domain.com/public_html/folder_outside_wordpress/undefined, referer: http://my_domain.com/folder_outside_wordpress/my_file.php
基本上,如果在他们的脚本中是/folder/file.php 而不是http://ads-domain.com/folder/file.php,我的日志文件中就会出现错误,这是正确的,因为我使用的是RewriteOptions Inherit。
所以,我的意思是只有在请求的文件丢失时才使用“RewriteOptions Inherit”行,就像这样。
if (status == 404)
{
RewriteOptions Inherit
ErrorDocument 404 /err/404.php
}
Apache 2.2.15 版
【问题讨论】: