I am trying to get pretty permalinks to function with OpenBSD httpd.
However, I cannot test my configurations because WordPress only offers the option of almost pretty permalinks.
What does WordPress use to determine if it should offer pretty permalinks as a configuration option?
If an answer or comment isn't explaining how WordPress performs this test, then it is not addressing the question.
I am trying to get pretty permalinks to function with OpenBSD httpd.
However, I cannot test my configurations because WordPress only offers the option of almost pretty permalinks.
What does WordPress use to determine if it should offer pretty permalinks as a configuration option?
If an answer or comment isn't explaining how WordPress performs this test, then it is not addressing the question.
Given that httpd is a very minor webserver by market share and didn't support rewrites until OpenBSD 6.6, it's not really surprising that WP hasn't been written to accommodate it.
The basic structure that WP requires is if the request is not for an extant file or directory, to rewrite it to index.php in the root of the site. You're going to have to implement that yourself. The guide at openbsdhandbook.com only acknowledges OpenBSD 6.4, so obviously there's no mention there of how it implements rewrites.
Otherwise, it might be a better idea to use a supported and better documented webserver like nginx.
Digging into it a little further: the actual test for rewriting is carried out by got_url_rewrite()
, which by default returns true if one of the below conditions is satisfied:
mod_rewrite
module is loaded$GLOBALS['is_nginx']
is set$GLOBALS['is_caddy']
is setiis7_supports_permalinks()
returns trueProvided you have rewrites correctly configured the below should work for you:
function wpse427660_got_rewrite() {
return true;
}
add_filter( 'got_url_rewrite', 'wpse427660_got_rewrite' );
Another option is to use $is_nginx
by placing the following line in functions.php
:
<?php
$is_nginx = ( str_contains( $_SERVER['SERVER_SOFTWARE'], 'OpenBSD httpd' ));
This will force WordPress to respond the same as it would with nginx
as it is the same test performed for nginx
in vars.php
[1]:
$is_nginx = ( str_contains( $_SERVER['SERVER_SOFTWARE'], 'nginx' ) );
Other things impacted by this can be discovered by searching the code base for is_nginx
.
[1] https://github.com/WordPress/wordpress-develop/blob/6.7.1/src/wp-includes/vars.php#L127
http://example.com/index.php/yyyy/mm/dd/post-name/
. See wordpress.org/documentation/article/customize-permalinks for more information. – Paul Commented Nov 22, 2024 at 12:40rewrite
rules) httpd, there is not a single post anywhere that has a configuration to support WordPress pretty permalinks. So I seem to be a trailblazer and the first problem I'm running into is WordPress doesn't offer the option of pretty permalinks, so I cannot tell if the configuration would work or not. – Paul Commented Nov 22, 2024 at 12:49