Permalinks: Detect Caddy web server support.

Support pretty permalinks when Caddy server is detected.

Props swissspidy, mukesh27, sadpencil, cfinnberg, viliamkopecky.
Fixes #41877.
Built from https://develop.svn.wordpress.org/trunk@57612


git-svn-id: http://core.svn.wordpress.org/trunk@57113 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Pascal Birchler 2024-02-13 10:08:14 +00:00
parent 9df3515569
commit 47df0cc10e
4 changed files with 13 additions and 5 deletions

View File

@ -39,11 +39,12 @@ function got_mod_rewrite() {
* @since 3.7.0 * @since 3.7.0
* *
* @global bool $is_nginx * @global bool $is_nginx
* @global bool $is_caddy
* *
* @return bool Whether the server supports URL rewriting. * @return bool Whether the server supports URL rewriting.
*/ */
function got_url_rewrite() { function got_url_rewrite() {
$got_url_rewrite = ( got_mod_rewrite() || $GLOBALS['is_nginx'] || iis7_supports_permalinks() ); $got_url_rewrite = ( got_mod_rewrite() || $GLOBALS['is_nginx'] || $GLOBALS['is_caddy'] || iis7_supports_permalinks() );
/** /**
* Filters whether URL rewriting is available. * Filters whether URL rewriting is available.

View File

@ -154,7 +154,7 @@ if ( $iis7_permalinks ) {
} else { } else {
$writable = false; $writable = false;
} }
} elseif ( $is_nginx ) { } elseif ( $is_nginx || $is_caddy ) {
$writable = false; $writable = false;
} else { } else {
if ( ( ! file_exists( $home_path . '.htaccess' ) if ( ( ! file_exists( $home_path . '.htaccess' )
@ -190,7 +190,7 @@ if ( $structure_updated ) {
'<code>web.config</code>' '<code>web.config</code>'
); );
} }
} elseif ( ! $is_nginx && $htaccess_update_required && ! $writable ) { } elseif ( ! $is_nginx && ! $is_caddy && $htaccess_update_required && ! $writable ) {
$message = sprintf( $message = sprintf(
/* translators: %s: .htaccess */ /* translators: %s: .htaccess */
__( 'You should update your %s file now.' ), __( 'You should update your %s file now.' ),

View File

@ -17,7 +17,7 @@
global $pagenow, global $pagenow,
$is_lynx, $is_gecko, $is_winIE, $is_macIE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone, $is_IE, $is_edge, $is_lynx, $is_gecko, $is_winIE, $is_macIE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone, $is_IE, $is_edge,
$is_apache, $is_IIS, $is_iis7, $is_nginx; $is_apache, $is_IIS, $is_iis7, $is_nginx, $is_caddy;
// On which page are we? // On which page are we?
if ( is_admin() ) { if ( is_admin() ) {
@ -126,6 +126,13 @@ $is_apache = ( str_contains( $_SERVER['SERVER_SOFTWARE'], 'Apache' ) || str_cont
*/ */
$is_nginx = ( str_contains( $_SERVER['SERVER_SOFTWARE'], 'nginx' ) ); $is_nginx = ( str_contains( $_SERVER['SERVER_SOFTWARE'], 'nginx' ) );
/**
* Whether the server software is Caddy or something else
*
* @global bool $is_caddy
*/
$is_caddy = ( str_contains( $_SERVER['SERVER_SOFTWARE'], 'Caddy' ) );
/** /**
* Whether the server software is IIS or something else * Whether the server software is IIS or something else
* *

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.5-alpha-57611'; $wp_version = '6.5-alpha-57612';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.