nginx重写:添加index.php

时间:2011-10-21 13:29:22

标签: nginx rewrite

如何在

中对nginx进行重写
http://www.example.com (with or without trailing slash)

在最后添加index.php?

对于上面的示例,结果应为

http://www.example.com/index.php

没有特殊的规则,只需要改变一个域。这应该很简单,但我似乎无法弄明白: - (

谢谢!

1 个答案:

答案 0 :(得分:1)

假设您想要更改用户的地址栏,您只需要在服务器块中添加一个额外位置:

location = / {
  return 301 http://www.example.com/index.php;
}