WordPress tries to detect the webserver’s type by peeking into the global $_SERVER['SERVER_SOFTWARE']
variable.
The Apache check is:
$is_apache = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false
|| strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false);
and the Nginx check is:
$is_nginx = (strpos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false);
You should therefore first check out:
var_dump( $_SERVER['SERVER_SOFTWARE'] );
to see if it’s correct.
Here are some alternative workarounds:
It’s also possible to avoid the .htaccess
file being created with:
add_filter( 'flush_rewrite_rules_hard', '__return_false' );
to avoid the save_mod_rewrite_rules()
to run.
Within the save_mod_rewrite_rules()
function, there’s a got_mod_rewrite()
check before the .htaccess
is updated. It’s also possible to use:
add_filter( 'got_rewrite', '__return_false' );
to avoid insert_with_markers()
to run that writes the .htaccess
file.