WordPress Pages Redirecting to Root with WordPress Multisite (Sub-Directory)


I am working with WordPress Multisite (with sub-directory structure). Everything works fine instead of WordPress pages. When I publish a page and I try to visit it, it redirects to the main multisite.

So for example, if the page is in this path:


it automatically redirects to:


Or another example, if the page is in this path:


it automatically redirects to:


I am using a plugin called Custom Permalinks to make posts URLs look nicer. I am using nginx as web server. I am developing the site, so currently on an IP, not a domain. I am redirecting the current root domain https://example.com/ to the main multisite path https://example.com/en-us/ with Redirection plugin.

This is my nginx conf file:

upstream php-handler-http {
    #server unix:/var/run/php5-fpm.sock;

map $http_host $blogid {
    default 0;
    include /var/www/html/wp-content/uploads/nginx-helper/map.conf;

server {
    listen 80 default_server;

    root /var/www/html/;
    index index.php;

    access_log /var/log/nginx/wordpress_http_access.log combined;
    error_log /var/log/nginx/wordpress_http_error.log;

    # set max upload size
    client_max_body_size 2G;
    fastcgi_buffers 64 4K;

    if (!-e $request_filename) {
        rewrite /wp-admin$ $scheme://$host$request_uri/ permanent;
        rewrite ^(/[^/]+)?(/wp-.*) $2 last;
        rewrite ^(/[^/]+)?(/.*.php) $2 last;

    location / {
        try_files $uri $uri/ /index.php?$args ;

    location ~ .php(?:$|/) {
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_pass php-handler-http;
        fastcgi_read_timeout 600;

    location = /favicon.ico {
        log_not_found off;
        access_log off;

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;

    location ~* .(htaccess|htpasswd) {
        deny all;

    # set long EXPIRES header on static assets
    location ~* .(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
        expires 24h;
        access_log off;

, , Alex 4 years 2020-03-27T04:52:23-05:00 0 Answers 125 views 0

Leave an answer