WordPress帖子名称固定链接重定向到Site.com

时间:2020-04-01 作者:Mr.Bhat

当permalink设置为plain 一切正常。但当我把permalink改为post name仅Wordpress主页(dev.site.com/blog) 工作正常,但对于其他页面(例如。,dev.site.com/blog/first-page) 它将重定向到dev.site.com.

server {
    listen 80;
    listen [::]:80;

    root /var/www/wordpress-site;
    index index.php index.html index.htm index.nginx-debian.html;

    server_name dev.site.com www.dev.site.com;

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { log_not_found off; access_log off; allow all; }

    location /blog {
            alias /var/www/wordpress-site/;
            try_files $uri $uri/ /blog/index.php?$args;

            location ~ \\.php$ {
                    include snippets/fastcgi-php.conf;
                    include fastcgi_params;
                    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
                    fastcgi_param SCRIPT_FILENAME $request_filename;
            }
    }

    # angular project

    location / {
            root /home/user/angular-project;
            try_files $uri $uri/ /index.html;
    }

    location ~ /\\.ht { deny all; }
}
我试着换衣服try_files, 但还是不行

谢谢:)

1 个回复
SO网友:harvey

尝试分离第二个位置块:

location /blog { alias /var/www/wordpress-site/; try_files $uri $uri/ /blog/index.php?$args; }

location ~ \\.php$ { fastcgi_split_path_info ^(/blog)(/.*)$; include snippets/fastcgi-php.conf; include fastcgi_params; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $request_filename; }

希望这有帮助!

相关推荐

带有WordPress多站点子域的Nginx通配符SSL

我有一个保护*的通配符证书。实例com和我需要删除所有子域请求的规范www,例如:www.subdomain1。实例com=>子域1。实例com公司我复习了这个问题:https://stackoverflow.com/questions/11323735/nginx-remove-www-and-respond-to-both但他们建议的第一个服务器块是:server { server_name www.example.com; return 301 $scheme://ex