nginx 下如何只把根目录下的 index.php 重写到 index.html ?
nginx 下如何只把根目录下的 index.php 重写到 index.html ?
|
rrfengNov 5, 2016
1
location = /index.php {
rewrite .... 或者 alias ...../index.html; } |
|
2
试了
location = /index\.php { rewrite index\.php /index.html break; } 和 location ~ /index\.php { rewrite index\.php /index.html break; } 都不行,能说具体点吗?谢了 |
|
3
@rrfeng 试了
location = /index\.php { rewrite index\.php /index.html break; } 和 location ~ /index\.php { rewrite index\.php /index.html break; } 都不行,能说具体点吗?谢了 |
|
kiwi95Nov 5, 2016
4
删了 index.php 这个文件, 然后:
``` try_files $uri /index.html; ``` |
|
5
@kiwi95 我试一下没有成功。这样写对吗?
location / { try_files /index.php /index.html; } 现在访问 index.php 是 file not found |
|
6
问个问题, index.php 接受参数传入吗?
否则, rewrite ^/index.php$ /index.html redirect; 直接写到 server {} 内,不需要 location |
|
7
@Bardon 可以了,好人一生平安!
|