Nginx rewrite rule for CodeIgniter

前端 未结 3 1489
抹茶落季
抹茶落季 2021-02-03 14:09

Here is the rule in English:

Any HTTP request other than those for index.php, assets folder, files folder and robots.txt is treated as a request for your

3条回答
  •  情歌与酒
    2021-02-03 15:01

    You want to do this instead:

    if ($request_uri !~ ^/(index\.php|assets|files|robots\.txt)) {
        rewrite ^/(.*)$ /index.php/$1 last;
    }
    

    $request_uri is for the original URI request by the client. If you want the URI request AFTER other Nginx rewrite rules have processed it then you would use $uri. However, for what you are trying to do the prior would be the one you would want.

    Also, you need to escape special regular expression characters like . by using a backslash.

提交回复
热议问题