using the Ubuntu + Hestia control panel (wildcard for subdomains “*.mydomain.com” In a WordPress Multi-Network (MultiSite within MultiNetwork with WP Multi Networks plugin) installation, each network runs as a subdomain (e.g. country.example.net) and each subsite must be created as a directory path (country.example.net/city/). After applying custom .htaccess rewrite rules, the redirect loop was resolved. But WordPress now returns a 404 Page not found, meaning it doesn’t recognize the routed paths.
My problem: Page not found Error code: 404
My .htaccess:
# BEGIN Hybrid MultiNetwork Rewrite
RewriteEngine On
# Protect admin, login, and REST endpoints
RewriteCond %{REQUEST_URI} ^/(wp-admin|wp-login\.php|wp-json|xmlrpc\.php) [NC]
RewriteRule .* - [L]
# Skip rewrite if 'country' or 'city' parameters already exist in the URL
RewriteCond %{QUERY_STRING} (^|&)(country|city)= [NC]
RewriteRule .* - [L]
# Apply only for subdomain-based network requests (e.g., country.example.net)
RewriteCond %{HTTP_HOST} ^([a-z0-9-]+)\.example\.net$ [NC]
# Ignore if the request points to an existing file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Ignore WordPress core and system folders
RewriteCond %{REQUEST_URI} !^/(wp-|index\.php|\.well-known|robots\.txt) [NC]
# Rewrite URLs like /city/ to index.php with country and city parameters
RewriteRule ^([a-z0-9-]+)/?$ index.php?country=%1&city=$1 [L,QSA]
# END Hybrid MultiNetwork Rewrite
My configuration.php:
if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' === strtolower( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ) {
$_SERVER['HTTPS'] = 'on';
$_SERVER['SERVER_PORT'] = 443;
}
/* Add any custom values between this line and the "stop editing" line. */
/* Multisite */
define( 'WP_ALLOW_MULTISITE', true );
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
define( 'DOMAIN_CURRENT_SITE', 'tifonder.net' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
My nginx.conf: /usr/local/hestia/data/templates/web/nginx/default-subdir.tpl
#=========================================================================#
# Default Web Domain Template #
# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS #
# https://hestiacp.com/docs/server-administration/web-templates.html #
#=========================================================================#
server {
listen %ip%:%proxy_port%;
server_name %domain_idn% %alias_idn%;
error_log /var/log/%web_system%/domains/%domain%.error.log error;
include %home%/%user%/conf/web/%domain%/nginx.forcessl.conf*;
location ~ /\.(?!well-known\/|file) {
deny all;
return 404;
}
# main block Proxy ל-Apache
location / {
proxy_pass http://%ip%:%web_port%;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
#
location ~* ^.+\.(%proxy_extensions%)$ {
root %docroot%;
access_log /var/log/%web_system%/domains/%domain%.log combined;
access_log /var/log/%web_system%/domains/%domain%.bytes bytes;
expires max;
try_files $uri =404;
}
location @fallback {
proxy_pass http://%ip%:%web_port%;
}
location /error/ {
alias %home%/%user%/web/%domain%/document_errors/;
}
}
error logs:
[Thu Oct 09 20:11:10.830172 2025] [proxy_fcgi:error] [pid 148919:tid 148919] [client 145.223.96.3:39508] AH01071: Got error 'PHP message: PHP Warning: Cannot modify header information - headers already sent by (output started at /home/james/web/mydomain.net/public_html/wp-includes/fonts/class-wp-font-face.php:121) in /home/james/web/mydomain.net/public_html/wp-includes/pluggable.php on line 1450PHP message: PHP Warning: Cannot modify header information - headers already sent by (output started at /home/james/web/mydomain.net/public_html/wp-includes/fonts/class-wp-font-face.php:121) in /home/james/web/mydomain.net/public_html/wp-includes/pluggable.php on line 1453', referer: https://mydomain.net/wp-admin/network/sites.php?page=hmnp-add-city-site
[Thu Oct 09 20:11:17.610234 2025] [core:error] [pid 148874:tid 148874] [client 145.223.96.3:53204] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
#WordPress #MultiNetwork #wildcard #subdomains #returning #custom #.htaccess #rewrite

