Loading... **答案是无需设置!!!** Caddy2 已经内置了关于``index.php``的伪静态! > That’s right, Caddy v2’s `php_fastcgi` directive is a shortcut that includes a `try_files` rewrite as you can see in the expanded form > > [Caddy社区](https://caddy.community/t/example-typecho-with-caddy2-dns-cloudflare/9476) 如果不放心还是想手动设置 ``` @key1 { not file path_regexp key1 (.*) } rewrite @key1 /index.php{re.key1.1} ``` 这样即可 [伪静态转换工具](https://www.toolnb.com/tools/rewriteTools.html) <div class="panel panel-default collapse-panel box-shadow-wrap-lg"><div class="panel-heading panel-collapse" data-toggle="collapse" data-target="#collapse-a254728498adad83abdc97c607b6501396" aria-expanded="true"><div class="accordion-toggle"><span style="">折叠内容</span> <i class="pull-right fontello icon-fw fontello-angle-right"></i> </div> </div> <div class="panel-body collapse-panel-body"> <div id="collapse-a254728498adad83abdc97c607b6501396" class="collapse collapse-content"><p></p> > The `php_fastcgi` directive is the same as the following configuration: ``` route { # Add trailing slash for directory requests @canonicalPath { file { try_files {path}/index.php } not path */ } redir @canonicalPath {path}/ 308 # If the requested file does not exist, try index files @indexFiles { file { try_files {path} {path}/index.php index.php split_path .php } } rewrite @indexFiles {http.matchers.file.relative} # Proxy PHP files to the FastCGI responder @phpFiles { path *.php } reverse_proxy @phpFiles <php-fpm_gateway> { transport fastcgi { split .php } } } ``` > Most modern PHP apps work well with this preset. If yours does not, feel free to borrow from this and customize it as needed instead of using the `php_fastcgi` shortcut. <p></p></div></div></div> 最后修改:2020 年 12 月 11 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 0 如果觉得我的文章对你有用,请随意赞赏