LoginSignup
17
17

More than 5 years have passed since last update.

nginxで /welcomeとかを静的ファイルにマッピングする

Last updated at Posted at 2014-03-19

/welcomeをwelcome.htmlにマッピング

/をindex.htmlにマッピング

css js 画像も配信できるように

location ~ ^/(index) {}がみそ。
/は/index.htmlに変換されてもう一度評価されるため、
上を書かないと、index.html.htmlなるファイルにアクセスしようとする。

listen 80;
server_name stg.mono-street.at;
access_log  /var/log/nginx/stg.access.log;
root /home/conoha/stg/htdocs;

location = / {
   add_header Content-type text/html;
   default_type text/html;
   index index.html;
   root /home/conoha/stg/htdocs;
}

location ~ ^/(index) {}

location ~ ^/([^/]+)$ {
  add_header Content-type text/html;
  default_type text/html;
  alias /home/conoha/stg/htdocs/$1.html;
}

location ~ .*\.(jpg|JPG|gif|GIF|png|PNG|swf|SWF|css|CSS|js|JS|inc|INC|ico|ICO) {
     root    /home/conoha/stg/htdocs/;
}
17
17
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
17
17