旧サーバー(Apache)はwordpressをドキュメントルートではなくサブディレクトリにインストールしていました
http://www.example.com/wordpress ← wordpress本体が入っているフォルダ
http://www.example.com/ ←トップページとしてwordpressが動く
そのため、wordpressの一般設定の処の設定が
WordPress アドレス (URL) http://www.example.com/wordpress
サイトアドレス (URL) http://www.example.com/
という設定になります
しかし、nginxではドキュメントルートにwordpressをインストールする設定にしていたため
サブディレクトリにインストールするように設定はしていませんでした
旧サーバーから新サーバーに移行する際にURLの変更をしようとするとどうしても上手くいかないので
同じURLにしたいと考えております
WordPress アドレス (URL) http://www.example.com/wordpress
サイトアドレス (URL) http://www.example.com/
wordpress本体はサブディレクトリであるhttp://www.example.com/wordpress の中にインストールしたいです
そのため、nginxでも、ドキュメントルートにwordpressをインストールするのではなく、
サブディレクトリにインストールするやり方、設定が知りたいです
そうすれば、旧サーバーと新サーバーで同じURLになると思いますので
データベースの変更などをしなくてすむので、レイアウト崩れや画像の欠落などもないのではないかと思います
以下のサイトを見つけたのですが、自分のexample.confにどのように追記したらいいのか迷っています
http://owani.net/wordpress/subdirectory/445/
server { listen 80; server_name owani.net; root /var/www/html; location / { try_files $uri $uri/ index.html index.php; } location @wp { rewrite ^/blog(.*) /blog/index.php?q=$1; } location ^~ /blog { root /var/www/html; index index.php index.html index.htm; try_files $uri $uri/ @wp; location ~ \.php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_pass 127.0.0.1:9000; } } }
以下の部分を追記したのですが、上手く反映されませんでした
# wordpressをサブディレクトリにインストールする方法 location @wp { rewrite ^/wordpress(.*) /wordpress/index.php?q=$1; } location ^~ /wordpress { root /usr/share/nginx/example/wordpress; index index.php index.html index.htm; try_files $uri $uri/ @wp; location ~ \.php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_pass 127.0.0.1:9000; } }
以下が自分の設定しているexample.conf
server { listen 80; server_name www.example; root /usr/share/nginx/example/wordpress; index index.php; charset utf-8; # wordpress パーマネントリンク設定 try_files $uri $uri/ /index.php?q=$uri&$args; # wp-config.phpへのアクセス拒否設定 location ~* /wp-config.php { deny all; } # php-fpm用設定 location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; include fastcgi_params; } # phpMyAdmin settings location /phpMyAdmin { alias /usr/share/phpMyAdmin/; index index.php; location ~ ^/phpMyAdmin/(.+\.php)$ { alias /usr/share/phpMyAdmin; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin/$1; fastcgi_param PATH_INFO $fastcgi_script_name; include fastcgi_params; } } # wordpressをサブディレクトリにインストールする方法 location @wp { rewrite ^/wordpress(.*) /wordpress/index.php?q=$1; } location ^~ /wordpress { root /usr/share/nginx/example/wordpress; index index.php index.html index.htm; try_files $uri $uri/ @wp; location ~ \.php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_pass 127.0.0.1:9000; } } }
回答1件
あなたの回答
tips
プレビュー