LoginSignup
0
0

More than 5 years have passed since last update.

nginxでtry_filesを使ってフロントコントローラにCleanURLを渡す

Posted at

今更ながらnginx+vagrantをはじめてみました。

nginxにはApacheのmod_rewrite相当のことを設定ファイルで書くようです(Apacheでも設定ファイルに書けます)。

フロントコントローラ型フレームワークで

のようなURL(CleanURL)を扱う場合、Apacheのmod_rewriteでURLの書き換えを行うわけですが、同様のことをnginxでする場合は、設定ファイルに以下のように記述すればいいようです。

server {
    location / {
        try_files $uri $uri/ /index.php?$request_uri;
    }
}

上記の例では、index.phpに対して「aaa/bbb/ccc」がREQUEST_URIとして渡されます。

0
0
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
0