nginx rewrite

nginx で rewrite

ファイルが無いときだけ、phpに渡す方法

server {
 listen       20961;
 root /home/www/web_api;

 access_log   /var/log/nginx/com.access.log  main;
 error_log   /var/log/nginx/com.error.log;

 location /bid/ {
   index   index.php index.html;
   try_files $uri @rewriteapp;
 }
 location @rewriteapp{
   rewrite ^/(.*)$ /index.php last;
 }
 location /index.php {
   fastcgi_pass unix:/var/run/php-fpm/www.socket;
   fastcgi_index index.php;
   include fastcgi_params;
 }
}

こんな感じで try_filesをして、ファイルが無い場合だけindex.phpにrewrite

参考

http://wiki.nginx.org/HttpCoreModule#try_files

http://wiki.nginx.org/Symfony

This entry was posted on 土曜日, 8月 31st, 2013 at 4:22 PM and is filed under nginx. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。