我的wordpress网站有一个nginx conf。这太重写了。 我想将重写替换为try_file并减少conf文件。
这是我的nginx conf:
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;
}
如何减少和更换它?谢谢。