我的 wordpress 网站有一个 nginx conf。重写太多了。我想将重写替换为 try_file 并减少 conf 文件。
这是我的 nginx 配置文件:
server
{
listen 80;
server_name domain.com www.domain.com;
index index.php;
root /home/domain.com;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ^~ /topics/ {
try_files $uri $uri/ /index.php;
rewrite ^/topics/(.*).html$ $scheme://$host/topics/$1/ permanent;
rewrite ^/topics/(.*).html/(.*)$ $scheme://$host/topics/$1/$2 permanent;
rewrite ^/topics/([0-9]+)/([0-9]+)/([0-9]+)/(.*)/$ $scheme://$host/topics/$4/ permanent;
rewrite ^/topics/([0-9]+)/([0-9]+)/([0-9]+)/(.*)/(.*)$ $scheme://$host/topics/$4/$5 permanent;
rewrite ^/topics/tag/(.*)$ $scheme://$host/tag/$1 permanent;
rewrite ^/topics/category/(.*)$ $scheme://$host/category/$1 permanent;
}
location ~ ^/topics/.+\.php$ {
set_real_ip_from 127.0.0.1;
real_ip_header X-Real-IP;
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
rewrite ^/([0-9]+)/([0-9]+)/([0-9]+)/(.*)/$ $scheme://$host/topics/$4/ permanent;
location ~ .*\.php(\/.*)*$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
set_real_ip_from 127.0.0.1;
real_ip_header X-Real-IP;
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
access_log off;
}
我怎样才能减少和更换它?谢谢你。