Permalinks: Detect Caddy web server support.

Support pretty permalinks when Caddy server is detected.

Props swissspidy, mukesh27, sadpencil, cfinnberg, viliamkopecky.
Fixes #41877.

git-svn-id: https://develop.svn.wordpress.org/trunk@57612 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler 2024-02-13 10:06:22 +00:00
parent 57b4193b9a
commit bffeb77d36
3 changed files with 12 additions and 4 deletions

View File

@ -39,11 +39,12 @@ function got_mod_rewrite() {
* @since 3.7.0
*
* @global bool $is_nginx
* @global bool $is_caddy
*
* @return bool Whether the server supports URL rewriting.
*/
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.

View File

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

View File

@ -17,7 +17,7 @@
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_apache, $is_IIS, $is_iis7, $is_nginx;
$is_apache, $is_IIS, $is_iis7, $is_nginx, $is_caddy;
// On which page are we?
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' ) );
/**
* 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
*