0

I'm setting up multisite on localhost in subdirectories.

The problem is that when I'm trying to access the dashboard of a site I just created ( localhost/wptest/site/wp-admin ) I get "This webpage has a redirect loop" and when I try to access the actual website ( localhost/wptest/site ) the page loads but without assets, such as css.

When I access the network dashboard, or the primary site dashboard on localhost/wptest everything is just fine. Also when I edit the permalink of the second site in the network dashboard, to be like this: localhost/site it also runs fine.

How to make it work with the default permalink structure localhost/wptest/site?

The wordpress files are in

/usr/share/html/wptest

The wp-config.php is as follows:

define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'localhost');
define('PATH_CURRENT_SITE', '/wptest/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

And the server block / virtual host is like this:

server {
    ##DM - uncomment following line for domain mapping  
    listen 80 default_server;
    #server_name example.com *.example.com ;
    ##DM - uncomment following line for domain mapping
    #server_name_in_redirect off;

    access_log   /var/log/nginx/example.com.access.log;
    error_log    /var/log/nginx/example.com.error.log;

    root /usr/share/nginx/html/wptest;
    index index.html index.htm index.php;

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

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

    location ~ \.php$ {
        try_files $uri /index.php;
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
    }

    location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
        access_log off; log_not_found off; expires max;
    }

    location = /robots.txt { access_log off; log_not_found off; }
    location ~ /\. { deny  all; access_log off; log_not_found off; }
}

And finally here's an error log:

2013/06/29 08:05:37 [error] 4056#0: *52 rewrite or internal redirection cycle while internally redirecting to "/index.php", client: 127.0.0.1, server: example.com, request: "GET /nginx HTTP/1.1", host: "localhost"
2
  • 1
    This question appears to be off-topic because it is about wp Jun 29, 2013 at 18:45
  • It think it's more about figuring nginx regular expressions in the server block? Jun 29, 2013 at 19:10

1 Answer 1

1

Try this - http://rtcamp.com/wordpress-nginx/tutorials/multisite/subdirectories/in-a-subdirectory/

You just need to tweak few lines. Replace wordpress with wptest in config at above URL.

Apart from that you might need some minor adjustments. Let me know how it goes!

2
  • Thank you! I don't know how I missed that, I was poking around those guides. It is working indeed, I only changed the root to point where my installation is /usr/share/nginx/html ; And changed wordpress to wptest of-course. I wonder what happens if in /html/ I have two multisites. Adding in the server block the locations and the rewrites for the second multisite would work? Jun 29, 2013 at 20:39
  • If you have two multisite in html, they will have their own folders. You can add few lines like location site1/ and location site2/ to separate requests. You will need to do some more tweaking.
    – rahul286
    Jul 1, 2013 at 11:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .