よろしくお願いいたします。
前提・実現したいこと
KUSANAGI for ConoHa にて、Nginx で WordPress と FuelPHP を以下のURLで動かしたいです。
URL | |
---|---|
WordPress | http://example.jp |
FuelPHP | http://example.jp/admin/{コントローラ名} |
* 通常/adminとするとwp-adminに飛ぶと思うのですが、そうせずFuelPHP側が表示されるように
# ディレクトリ
/
└ home/
└ kusanagi/
└ www/
└ wp-config.php
└ DocumentRoot/
└ wp-admin/
└ wp-content/
...
└ admin/
└ fuel/
└ public/
└ index.php
発生している問題・エラーメッセージ
Nginxのconfファイルがうまく書けず
- http://example.jp/adminにアクセスしても、FuelPHPのwelcomeがでない
- http://example.jp/admin/hogeにアクセスすると、WordPresのPage not foundが出る
該当のソースコード
# /etc/nginx/conf.d/www_http.conf
server {
listen 80;
server_name example.jp;
access_log /home/kusanagi/www/log/nginx/access.log main;
error_log /home/kusanagi/www/log/nginx/error.log warn;
# rewrite ^(.*)$ https://example.jp$request_uri permanent; # SSL ONLY
charset UTF-8;
client_max_body_size 16M;
root /home/kusanagi/www/DocumentRoot;
index index.php index.html index.htm;
location /admin {
alias /home/kusanagi/www/admin/public;
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ ^/admin/.+\.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param FUEL_ENV "production";
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location / {
try_files $uri $uri/ /index.php?$args;
}
...
# /home/kusanagi/www/DocumentRoot/.htaccess
<Files ~ "^\.ht">
Deny from all
</Files>
<Files wp-login.php>
Order deny,allow
Deny from all
Allow from all
#Allow from 127.0.0.1
AuthType Basic
AuthName "ENTER YOUR NAME & PASSWORD TO LOGIN"
AuthUserFile /home/kusanagi/.htpasswd
Require valid-user
Satisfy any
</Files>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !\.(gif|css|js|swf|jpeg|jpg|jpe|png|ico|swd|pdf|svg|eot|ttf|woff) $
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# /home/kusanagi/www/admin/public/.htaccess
# Multiple Environment config, set this to development, staging or production
SetEnv FUEL_ENV development
# SetEnv FUEL_ENV production
<IfModule mod_rewrite.c>
# RewriteEngine を起動
RewriteEngine on
# NOTICE: If you get a 404 play with combinations of the following commented out lines
#AllowOverride All
#RewriteBase /wherever/fuel/is
RewriteBase /admin
# Make sure directory listing is disabled
# Options +FollowSymLinks -Indexes
# Restrict your site to only one domain
# !important USE ONLY ONE OPTION
# Option 1: To rewrite "www.domain.com -> domain.com" uncomment the following lines.
#RewriteCond %{HTTPS} !=on
#RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Option 2: To rewrite "domain.com -> www.domain.com" uncomment the following lines.
#RewriteCond %{HTTPS} !=on
#RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
#RewriteCond %{HTTP_HOST} (.+)$ [NC]
#RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
# Remove index.php from URL
RewriteCond %{HTTP:X-Requested-With} !^XMLHttpRequest$
RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
RewriteRule ^index\.php(.*)$ $1 [R=301,NS,L]
DirectorySlash Off
RedirectMatch permanent /admin$ /admin/login
RedirectMatch permanent /admin/$ /admin/login
# make HTTP Basic Authentication work on php-fcgi installs
<IfModule mod_fcgid.c>
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
# Send request via index.php if not a real file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# deal with php-fcgi first
<IfModule mod_fcgid.c>
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
# no php-fcgi, check for sapi and fpm
<IfModule !mod_fcgid.c>
# for PHP5 sapi installations
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_php5.c>
# for PHP7 sapi installations
<IfModule mod_php7.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
# for fpm installations
<IfModule !mod_php7.c>
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
</IfModule>
</IfModule>
</IfModule>
補足情報(言語/FW/ツール等のバージョンなど)
バージョン | |
---|---|
Nginx | nginx/1.11.10 |
PHP | 5.6.30 (php7にしたいが、kusanagi php7してもなぜか切り替わらない) |
WordPress | 4.7.3 |
FuelPHP | 1.8 |
-
気になる質問をクリップする
クリップした質問は、後からいつでもマイページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
クリップを取り消します
-
良い質問の評価を上げる
以下のような質問は評価を上げましょう
- 質問内容が明確
- 自分も答えを知りたい
- 質問者以外のユーザにも役立つ
評価が高い質問は、TOPページの「注目」タブのフィードに表示されやすくなります。
質問の評価を上げたことを取り消します
-
評価を下げられる数の上限に達しました
評価を下げることができません
- 1日5回まで評価を下げられます
- 1日に1ユーザに対して2回まで評価を下げられます
質問の評価を下げる
teratailでは下記のような質問を「具体的に困っていることがない質問」、「サイトポリシーに違反する質問」と定義し、推奨していません。
- プログラミングに関係のない質問
- やってほしいことだけを記載した丸投げの質問
- 問題・課題が含まれていない質問
- 意図的に内容が抹消された質問
- 過去に投稿した質問と同じ内容の質問
- 広告と受け取られるような投稿
評価が下がると、TOPページの「アクティブ」「注目」タブのフィードに表示されにくくなります。
質問の評価を下げたことを取り消します
この機能は開放されていません
評価を下げる条件を満たしてません
質問の評価を下げる機能の利用条件
この機能を利用するためには、以下の事項を行う必要があります。
- 質問回答など一定の行動
-
メールアドレスの認証
メールアドレスの認証
-
質問評価に関するヘルプページの閲覧
質問評価に関するヘルプページの閲覧
checkベストアンサー
0
/home/kusanagi/www/DocumentRoot/.htaccess
について、/admin/ に関するルールがないために、
全部wordpressのindex.phpに処理が飛ばされています。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^admin/(.*) admin/$1 [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !\.(gif|css|js|swf|jpeg|jpg|jpe|png|ico|swd|pdf|svg|eot|ttf|woff) $
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
「RewriteBase /」の直後に「RewriteRule ^admin/(.*) admin/$1 [L]」を入れて、
admin/~~へのリクエストをそっちに強制的に飛ばす、
というのを入れたらいかがでしょうか。
投稿
-
回答の評価を上げる
以下のような回答は評価を上げましょう
- 正しい回答
- わかりやすい回答
- ためになる回答
評価が高い回答ほどページの上位に表示されます。
-
回答の評価を下げる
下記のような回答は推奨されていません。
- 間違っている回答
- 質問の回答になっていない投稿
- スパムや攻撃的な表現を用いた投稿
評価を下げる際はその理由を明確に伝え、適切な回答に修正してもらいましょう。
15分調べてもわからないことは、teratailで質問しよう!
- ただいまの回答率 88.09%
- 質問をまとめることで、思考を整理して素早く解決
- テンプレート機能で、簡単に質問をまとめられる
質問への追記・修正、ベストアンサー選択の依頼
m6u
2017/03/08 20:57 編集
.htaccessはどうなってますか? ルートディレクトリの .htaccess でのurlリライト絡みのトラブルと推察
m055001
2017/03/08 21:50
.htaccessの情報を追加しました!どちらかわからなかったのでwordpressとfuel両方追加しました。Nginxを使用しているのですが、.htaccessはどのように関係してくるのでしょうか?