如何在nginx中重定向到索引文件

时间:2012-10-22 14:23:19

标签: nginx

我有一个简单的例子:

   location / {
        rewrite  ^/$  /index.html  last;
        root /test/;
        fastcgi_pass 127.0.0.1:7777;
        include fastcgi_params;
    }

如何将“/”重定向到/index.html?

1 个答案:

答案 0 :(得分:0)

将以下指令添加到配置中(并删除重写)

index index.html; 

会告诉nginx将index.html用于任何目录, 有关详细信息,请参阅http://nginx.org/en/docs/http/ngx_http_index_module.html#index

虽然给出fastcgi位你可能想要index.php吗?

通常您还希望将根移动到服务器块而不是位置块(以便不必在每个位置块中重复自己)