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