Wordpress 重定向-htcaccess还是cloudflare?
我的客户网站有问题 问题在于,URL上似乎存在不存在/没有内容的重定向: 然而,如果我们将结束URL更改为另一个没有内容/不存在的URL,我们将获得正确的页面加载(即页面不存在) === 在/URL上似乎有某种重定向 问题是,当一个页面被创建时,以URL/liverpool结尾-不可能使用这个URL,因为wordpress认为它已经被使用了 我可能遗漏了一些明显的错误,但我需要以某种方式清除/liverpool URL,以便可以使用内容,并确保使用/liverpool创建包含内容的页面时没有重定向 有人能帮忙吗 ----检查此重定向时,以下是输出。我已检查clourflare,但看不到任何重定向设置: 结果: HTTP/1.1 301永久移动 日期:2020年9月25日星期五10:08:36 GMT 内容类型:text/html;字符集=iso-8859-1 传输编码:分块 连接:保持活力 设置Cookie:uu cfduid=d440b3cca7954a48bdc3f84b50e73ea7a1601028515;expires=太阳,20年10月25日10:08:35格林威治标准时间;路径=/;域名=.henparty-houses.com;HttpOnly;SameSite=Lax 地点: 缓存控制:最大年龄=0 过期时间:2020年9月25日星期五10:08:36 GMT 主机头:b7440e60b07ee7b8044761568fab26e8 X-Proxy-Cache:未命中 CF缓存状态:动态 cf请求id:056655801200000ED6FCAA5220000001 服务器:cloudflare CF-RAY:5d83f1e01a84ed6f SJC HTTP/2302 日期:2020年9月25日星期五10:08:39 GMT 内容类型:text/html;字符集=UTF-8 设置cookie:uu cfduid=D974040F170C5090B9A4 E61AAF9590D1B61601028518;expires=Sun,20年10月25日10:08:38格林威治标准时间;路径=/;域名=.henparty-houses.com;HttpOnly;SameSite=Lax 启用x缓存:True p3p:CP=“所有的数字信号处理器都不支持我们的导航数据” x-redirect-by:WordPress 地点: 缓存控制:最大年龄=0 过期时间:2020年9月25日星期五10:08:38 GMT 主机头:b7440e60b07ee7b8044761568fab26e8 x-proxy-cache:未命中 cf缓存状态:动态 cf请求id:05665588C80009623CA33E200000001 预期ct:最大年龄=604800,报告uri=”https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" 服务器:cloudflare cf射线:5d83f1ee09ee9623 SJC HTTP/2200 日期:2020年9月25日星期五10:08:41 GMT 内容类型:text/html;字符集=UTF-8 设置cookie:uu cfduid=d63a3cce54fa1ec1e3d8bbf7c7415b8d1601028519;expires=Sun,20年10月25日10:08:39格林威治标准时间;路径=/;域名=.henparty-houses.com;HttpOnly;SameSite=Lax 启用x缓存:True p3p:CP=“所有的数字信号处理器都不支持我们的导航数据” 链接:;rel=”https://api.w.org/", ; rel=“备用”;type=“application/json”;rel=短链接 改变:接受编码 缓存控制:最大年龄=0 过期时间:2020年9月25日星期五10:08:40 GMT 主机头:b7440e60b07ee7b8044761568fab26e8 x-proxy-cache:未命中 cf缓存状态:动态 cf请求id:0566558F4E0000930A5D2F820000001 预期ct:最大年龄=604800,报告uri=”https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" 服务器:cloudflareWordpress 重定向-htcaccess还是cloudflare?,wordpress,Wordpress,我的客户网站有问题 问题在于,URL上似乎存在不存在/没有内容的重定向: 然而,如果我们将结束URL更改为另一个没有内容/不存在的URL,我们将获得正确的页面加载(即页面不存在) === 在/URL上似乎有某种重定向 问题是,当一个页面被创建时,以URL/liverpool结尾-不可能使用这个URL,因为wordpress认为它已经被使用了 我可能遗漏了一些明显的错误,但我需要以某种方式清除/liverpool URL,以便可以使用内容,并确保使用/liverpool创建包含内容的页面时没有
cf ray:5d83f1f87ede930a SJC我认为您不会在
.htaccess
文件中找到答案。从标题中可以看到,重定向是由WordPress本身发出的
x-redirect-by: WordPress
如果转到WordPress安装目录,可以使用以下命令查找设置此标题的函数
grep --line-number --with-filename --fixed-strings -i -R 'x-redirect-by' .
结果很简单:
./wp-includes/pluggable.php:1284: * Filters the X-Redirect-By header.
./wp-includes/pluggable.php:1296: header( "X-Redirect-By: $x_redirect_by" );
毫不奇怪,设置此标头的函数名为wp\u redirect
简而言之,问题可能不是服务器配置。我认为正在发生的是,您的一个页面的slug设置为liverpool
通常,当WordPress收到对不存在的页面的请求时(触发404
错误),它会首先尝试将请求重定向到“规范”URL(请参阅)。这些规范URL称为“slug”
如果现有页面中有一个slug设置为liverpool
,这将触发URL规范化过程。因此,可能该页面被设置为隐藏,或者手动重定向用户,因为它需要用户登录,或者其他很多事情。无论哪种方式,手动重定向都是执行302
重定向的原因。要想知道到底发生了什么,最好的办法是找到包含特定slug的页面
我倾向于相信页面现在存在的原因是302
意味着找到了。如果某个页面以前使用了一段liverpool
,然后对其进行了更改,则正确的响应应该是永久移动301
,并重定向到该页面的当前版本。我的想法是,存在一个页面,其中包含一个slug of liverpool,它有意地将客户重定向到主页。因此,解决方案很可能是向下跟踪这一页
通过直接访问数据库,而不是通过用户界面,可以显著加快此过程。wp_posts
表包含大部分页面内容(请参阅以获得更深入的解释),而wp_postmeta
表包含post元数据
我首先运行这样一个查询(我假设您使用的是MariaDB或MySQL,但是Postgres或任何查询都是类似的,如果不相同的话)
这个查询应该可以让您接近。如果在那里找不到任何内容,您可能需要查看wp\u postemta
表。根据站点数据库的大小,在UI中一页一页地手动检查可能会更容易,因为很多条目要么是序列化对象、HTML,要么通常很难进行可视化解析
SELECT `wp_postmeta`.* FROM `wp_postmeta`;
显然,您可以在这里使用另一个类似于
的子句,在运行此子句之前,首先尝试一下可能会有所帮助。请记住,它可能需要一段时间才能运行,因为它必须根据
SELECT `wp_postmeta`.* FROM `wp_postmeta`;
DESCRIBE `wp_postmeta`;
DESCRIBE `wp_posts`;
/**
* Redirects to another page.
*
* Note: wp_redirect() does not exit automatically, and should almost always be
* followed by a call to `exit;`:
*
* wp_redirect( $url );
* exit;
*
* Exiting can also be selectively manipulated by using wp_redirect() as a conditional
* in conjunction with the {@see 'wp_redirect'} and {@see 'wp_redirect_location'} filters:
*
* if ( wp_redirect( $url ) ) {
* exit;
* }
*
* @since 1.5.1
* @since 5.1.0 The `$x_redirect_by` parameter was added.
* @since 5.4.0 On invalid status codes, wp_die() is called.
*
* @global bool $is_IIS
*
* @param string $location The path or URL to redirect to.
* @param int $status Optional. HTTP response status code to use. Default '302' (Moved Temporarily).
* @param string $x_redirect_by Optional. The application doing the redirect. Default 'WordPress'.
* @return bool False if the redirect was cancelled, true otherwise.
*/
function wp_redirect( $location, $status = 302, $x_redirect_by = 'WordPress' ) {
global $is_IIS;
/**
* Filters the redirect location.
*
* @since 2.1.0
*
* @param string $location The path or URL to redirect to.
* @param int $status The HTTP response status code to use.
*/
$location = apply_filters( 'wp_redirect', $location, $status );
/**
* Filters the redirect HTTP response status code to use.
*
* @since 2.3.0
*
* @param int $status The HTTP response status code to use.
* @param string $location The path or URL to redirect to.
*/
$status = apply_filters( 'wp_redirect_status', $status, $location );
if ( ! $location ) {
return false;
}
if ( $status < 300 || 399 < $status ) {
wp_die( __( 'HTTP redirect status code must be a redirection code, 3xx.' ) );
}
$location = wp_sanitize_redirect( $location );
if ( ! $is_IIS && 'cgi-fcgi' !== PHP_SAPI ) {
status_header( $status ); // This causes problems on IIS and some FastCGI setups.
}
/**
* Filters the X-Redirect-By header.
*
* Allows applications to identify themselves when they're doing a redirect.
*
* @since 5.1.0
*
* @param string $x_redirect_by The application doing the redirect.
* @param int $status Status code to use.
* @param string $location The path to redirect to.
*/
$x_redirect_by = apply_filters( 'x_redirect_by', $x_redirect_by, $status, $location );
if ( is_string( $x_redirect_by ) ) {
header( "X-Redirect-By: $x_redirect_by" );
}
header( "Location: $location", true, $status );
return true;
}