0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

hogeプロジェクトにbarでアクセスする設定

Posted at
nginx.conf
# location プレフィックス
# = 完全一致 
# ^~ 前方一致。一致したら正規表現を適用しない。 
# ~ 正規表現(大文字・小文字を区別する) 
# ~* 正規表現(大文字・小文字を区別しない) 
# なし 前方一致 
location /bar {
    # よくわからん時はエラーログを参考にする
    # error_log logs/laravel_error.log  debug;

    # rootとalias違い
    # root → /nginx/html/hoge/public/bar
    # alias → /nginx/html/hoge/public
    alias /nginx/html/hoge/public;
    
    # try_files
    # $uri $uri/ ファイル検索
    # /index.php?$query_string rewriteと同様
    try_files $uri $uri/ /index.php?$query_string;
    
    # /hoge/foo にアクセスがあった場合はファイルがないので
    # rewriteして再評価している
    # REQUEST_URIは変更されずlaravelで読み込まれる
    if (!-e $request_filename) { rewrite ^ /bar/index.php last; }
    
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        include        fastcgi_params;
        # laravelはindex.phpしかアクセスしない
	fastcgi_param SCRIPT_FILENAME $document_root/index.php;
    }
}
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?