问题描述
我正在尝试创建一个自定义 URL,我将在其中输出一些字符串。问题是我希望这个 URL 包含一个 /.well-kNown/
目录,当我这样做时,会发生 403 禁止错误。所以我当前的代码在没有目录的情况下工作,而不是在 /.well-kNown/
目录下工作。这是我的代码:
add_action('parse_request','custom_output');
function custom_output() {
global $wp;
global $wp_query;
$urlEnd = 'custom-output'; // This will work
$desiredUrlEnd = '.well-kNown/custom-output'; // This will not work
if (!$wp_query->is_main_query()) {
return;
}
if ($wp->request === $desiredUrlEnd) {
$wp_query->set($desiredUrlEnd,1);
}
if ($wp_query->get($desiredUrlEnd)) {
@ini_set('display_errors',0);
@header('Cache-Control: no-cache');
@header('X-Robots-Tag: noindex,follow');
echo 'custom output';
exit;
}
}
所以它适用于 $urlEnd
并且输出显示在 https://example.com/custom-output
上,但它不适用于 $desiredUrlEnd
并且在我访问 https://example.com/.well-kNown/custom-output
时会导致错误。我怎样才能让它工作?
谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)