本文最后更新于 1446 天前,其中的信息可能已经有所发展或是发生改变。
答案是无需设置!!!
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社区
如果不放心还是想手动设置
@key1 {
not file
path_regexp key1 (.*)
}
rewrite @key1 /index.php{re.key1.1}
这样即可
伪静态转换工具
折叠内容
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.