Wordpress multisite from apache to nginx

Discussion in 'ISPConfig 3 Priority Support' started by DylanPedro, Feb 7, 2018.

  1. DylanPedro

    DylanPedro Member

    Hi,

    I've moved our existing wordpress multisite from an apache setup to a ISPConfig nginx setup.

    The whole site was in a folder called "wordpress" so the whole folder has been placed in the parent sites "web" folder.

    Then all extra sites have been created using the aliasdomains feature.

    The other sites appear to work and the homepage loads but when clicking any of the links a 404 not found page is shown. Checking the logs shows the url requested cannot be found when using fancy permalinks e.g.
    http://example.com/?p=123 is represented as:
    http://example.com/2018/02/07/sample-post/
    then it does not work

    but if the default setting is used so all links are like:
    http://example.com/?p=123

    Then it works.

    I am guessing this is a rewrite issues with nginx as it does not use the .htaccess files but what do I need to add to the nginx directives and where to get it to work?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Try this in nginx directives field of the website:

    Code:
    location / {
                    try_files $uri $uri/ /index.php?$args;
           }
           # Add trailing slash to */wp-admin requests.
           rewrite /wp-admin$ $scheme://$host$uri/ permanent;
           location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
                    expires max;
                    log_not_found off;
           }
     
  3. DylanPedro

    DylanPedro Member

    Where do I enter this? As the Wordpress folder has been added as proxy rather than being served from the web folder
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    The directives are for WordPress installation in an ISPConfig nginx website and the directives field is on the options tab of that site. If you used a different setup, then I don't have any matching directives for you.
     
  5. DylanPedro

    DylanPedro Member

    Hi Till,

    This worked but when hovering over images or copying their url's the url should be:
    site2.com/....imagename.jpg
    but instead is like this:
    site2.site1.com/....imagename.jpg

    The problem with this is it reveals the domain of the main network and it shouldn't.

    site2 is a subdomain site and site1 is the main network for the multisite?
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Check the html to see which URL the images use. If the URL in html contains the wrong domain, then it's a wordpress issue.
     
  7. DylanPedro

    DylanPedro Member

    I just check the config file for this particular site as I have added the folder as a proxy and the settings say it has to be in the format:
    /foldername/ which I have added as /wordpress/
    Code:
    server {
            listen *:80;
    
            listen *:443 ssl;
                    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
            ssl_certificate /var/www/clients/client0/web6/ssl/example.com-le.crt;
            ssl_certificate_key /var/www/clients/client0/web6/ssl/example.com-le.key;
    
            server_name example.com www.example.com www.example2.com example2.com;
    
            root   /var/www/example.com/web//wordpress;
    
    
    
            index index.html index.htm index.php index.cgi index.pl index.xhtml;
    
    Problem is the configs show the folder name with an additions '/' before the wordpress folder?
     

Share This Page