Skip to content

Commit 7ca6a24

Browse files
committed
fix: align trailingslash redirects with permalink settings
Ensure /example-page/ correctly redirects to /example-page to stay consistent with core WordPress permalink behavior.
1 parent e7b31ab commit 7ca6a24

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

includes/dropins/page-cache.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,15 @@ function powered_cache_serve_cache() {
486486
}
487487

488488
// trailingslash check
489-
if ( isset( $powered_cache_slash_check ) && $powered_cache_slash_check ) {
489+
if ( isset( $powered_cache_slash_check ) ) {
490490
$current_path = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
491-
if ( ! empty( $current_path ) && '/' !== substr( $current_path, - 1 ) ) {
491+
if ( $powered_cache_slash_check && ! empty( $current_path ) && '/' !== substr( $current_path, - 1 ) ) {
492+
header( 'X-Powered-Cache: Passing to WordPress' );
493+
494+
return;
495+
}
496+
497+
if ( ! $powered_cache_slash_check && ! empty( $current_path ) && '/' === substr( $current_path, - 1 ) ) {
492498
header( 'X-Powered-Cache: Passing to WordPress' );
493499

494500
return;

0 commit comments

Comments
 (0)