版权声明:
尊重知识产权,严厉打击非法采集。
这是一个关于Wordpress完整的Nginx配置例子,配置有url rewrite 。
基本配置
server {
listen 80;
server_name www.hooyes.net;
#include restrictions.conf;
location / {
# 简单地址重写
#if (!-e $request_filename) {
# rewrite (.*) /index.php;
#}
# 完整地址重写
rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
if (!-e $request_filename) {
rewrite ^.+/?(/wp-.*) $1 last;
rewrite ^.+/?(/.*\.php)$ $1 last;
rewrite ^(.+)$ /index.php?q=$1 last;
}
root /wwwroot/wordpress/;
index index.html index.htm index.php;
}
location ~ \.php$ {
root /wwwroot/wordpress/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
目录安全配置 restrictions.conf
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# 禁止访问所有的隐藏文件例如 .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
}
# 禁止访问uploads目录中的任何php文件
location ~ ^/wp-content/uploads/.*\.php$ {
deny all;
}
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
$ welcome to hooyes.net
[INFO] ------------------------------o-
[INFO] Author : HOOYES
[INFO] Site : https://hooyes.net
[INFO] Page : https://hooyes.net/p/wordpress-nginx-rewrite
[INFO] Last build : 2023-07-31 09:16:20 +0000
[INFO] -0------------------------------
上一篇 冒泡法排序
下一篇 你可能不再需要jQuery