-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-general.conf
41 lines (34 loc) · 1.58 KB
/
wp-general.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# /etc/nginx/sites-available/wp-general.conf
# pass PHP scripts to FastCGI server
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
# With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
client_max_body_size 20m;
fastcgi_connect_timeout 30s;
fastcgi_send_timeout 30s;
fastcgi_read_timeout 30s;
fastcgi_intercept_errors on;
}
#处理根目录的请求。try_files 指令按顺序检查文件是否存在,如果没有找到静态文件,请求将重写到 /index.php
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
#处理静态资源文件的请求,设置它们的缓存过期时间为最大值,并关闭日志记录。
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
if (!-e $request_filename) {
#如果请求以 /wp-admin 结尾(不包括斜杠),则永久重定向到包含尾随斜杠的 URL。
#这是为了修复 WordPress 后台登录时的重定向问题。
rewrite /wp-admin$ $scheme://$host$request_uri/ permanent;
#对于指向 WordPress 核心文件的请求,如果 URL 中包含站点的子目录名称,则去除子目录部分,直接重写到相应文件。
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
#对于指向 PHP 文件的请求,同样去除 URL 中的子目录部分。
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}