Caddy2如何为Typecho设置伪静态
答案是无需设置!!!
Caddy2 已经内置了关于index.php的伪静态!
That’s right, Caddy v2’s
php_fastcgidirective is a shortcut that includes atry_filesrewrite as you can see in the expanded form
如果不放心还是想手动设置
@key1 {
not file
path_regexp key1 (.*)
}
rewrite @key1 /index.php{re.key1.1}
这样即可
[collapse status=“false” title=“折叠内容”]
The
php_fastcgidirective 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_fastcgishortcut.
[/collapse]