Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
285 views
in Technique[技术] by (71.8m points)

php - Second Wordpress site in subdirectory of first Wordpress site returns 404 using NGINX server block

I have a Wordpress site on root, and a second Wordpress site in subdirectory /blog. I have been tasked with migrating these two Wordpress installs from one server to another. Here is the folder structure on the Ubuntu server:

    /var/www/html/example.com/html        # WP install 1
    /var/www/html/example.com/html/blog   # WP install 2

The old server works fine, however visiting https://example.com/blog (or any folder within) on the new server returns a 404 error.

Below is the configuration file, /etc/nginx/sites-available/example.com

    server {
        listen 80 default_server;
        listen [::]:80 default_server;
        
        root /var/www/example.com/html;

        index index.html index.htm index.php;

        server_name example.com www.example.com;

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

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

        location ~ .php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        }
    }

While I have been very careful to ensure the databases and directory structure match across the servers, one difference is the php has been updated on the new server from 7.0 to 7.4.

I have tried a variety of different configurations to get this to work, but so far I have not been successful. Any assistance would be greatly appreciated.

question from:https://stackoverflow.com/questions/65851812/second-wordpress-site-in-subdirectory-of-first-wordpress-site-returns-404-using

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Okay, SOLVED. I made a mistake and imported the same database for both WP installs, and went down this rabbit hole instead of checking the databases. The configuration file is correct, just as it always was. Whew!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...