-1

nginx で単一のサイト構成ファイルを使用して、サブフォルダーに任意の数の WordPress インストールをサーバーしようとしていますが、きれいなパーマリンクをまったく機能させることができません。

+ root
    + WordPressOne
    + WordPressTwo
    + WordPressThree

パーマリンクを無効にすると、正常に/WordPressOne/?p=12動作します。パーマリンクを有効にすると/WordPressOne/MyPage/、ルート フォルダーから 404 が配信されます。

サブフォルダー内の WP インストールの数は常に変化しているため (開発に使用されます)、サイト構成を常に変更/作成/削除する必要がないため、新しいものをコピーできるようにしたいと考えています。 WordPress を新しいサブフォルダーにインストールし、WP をセットアップし、nginx または PHP-FPM を再起動せずにそのインストールでパーマリンクを機能させます。

site.confこれは、フォルダで使用される基本です/etc/nginx/sites-available/(これは、本番環境でも使用される多くのルールを反映しています)。

server {
    listen 5000 default;
    server_name dev wpdev;
    root /vagrant/sites;
    client_max_body_size 2m;
    expires -1;
    charset utf-8;
    index index.html index.php;

    location ~* ^.+\.(manifest|appcache)$ {
        expires -1;
        index index.html index.htm;
        uwsgi_cache off;
    }

    location ~* \.(?:rss|atom)$ {
        expires 1h;
        add_header Cache-Control "public";
    }

    location ~* ^.+\.(css    |js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm|txt)$ {
        expires max;
        access_log off;
        index index.html index.htm;
        add_header Cache-Control "public";
        uwsgi_cache off;
    }

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

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        uwsgi_cache off;
        include /etc/nginx/fastcgi_params;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
    }

    location ~ /\.ht {
        deny all;
    }

    add_header "X-UA-Compatible" "IE=Edge,chrome=1";
    add_header "Vary" "Accept-Language";
    add_header "Access-Control-Allow-Origin" "*";
    add_header "Cache-Control" "no-transform";
}

これは仮想マシン構成の一部としても使用されます (ご覧のとおり、Vagrant を使用)。デザイナーや WP 開発者が nginx のサイト ファイルを最新の状態に保つことを心配する必要がないようにしたいと思います。

ありがとう!

4

1 に答える 1