简体   繁体   English

Wordpress Nginx永久链接从纯名称到邮政名称

[英]Wordpress Nginx Permalink from plain to postname

I'm trying to change from plain http://sitename/?p=123 to http://sitename/postname with rewrite rule but it gives error 404 Not found. 我正在尝试使用重写规则将普通的http:// sitename /?p = 123更改为http:// sitename / postname ,但它给出错误404 Not found。 This is my nginx server block code: 这是我的nginx服务器块代码:

server {

        listen 80;
        listen 443 ssl;

        root /var/www/sitename/html;
        index index.php index.html index.htm;

        server_name sitename www.sitename;
        client_max_body_size 10M;

        # Certificates handled by CertBot

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

        location / {
                server_name sitename www.sitename;
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                # try_files $uri $uri/ /index.php$is_args$args;
                # rewrite ^ http://$server_name$request_uri permanent;
                rewrite ^/(.*)$ http://$server_name/$1 permanent;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
                # root /data/www;
                # index index.html index.htm;
        }
}

I want to use rewrite so I redirect https of front-end to http and wp-admin and wp-login as https which is handled by Wordpress. 我想使用重写,所以我将前端的https重定向到http和wp-admin和wp-login作为由Wordpress处理的https。

How can I fix it? 我该如何解决?

Created a separate similar server block with 443 listen. 用443个监听创建了一个单独的类似服务器块。 Included the cert lines and removed the location from 443 block. 包括证书行,并从443块中删除了该位置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WordPress%postname%permalink返回404 - WordPress %postname% permalink returns 404 手动将 WordPress 数据库从域转移到另一个域,在固定链接中使用 postname - Manually transfer WordPress database from domain to another domain with postname in permalink 设置为postname时,WordPress永久链接不起作用 - Wordpress permalink is not working when set to postname 将所有博客文章从 %postname% 永久链接结构重定向到 /news/%postname% - Redirect all blog posts from %postname% permalink structure to /news/%postname% 将永久链接结构更改为postname时,Wordpress localhost产生404页 - Wordpress localhost results in 404 pages when changing permalink structure to postname Wordpress Postname 永久链接在 localhost (xampp) 上不起作用 - Wordpress Postname permalink doesn't work on localhost (xampp) 分页不适用于固定链接的邮政名 - pagination not working with permalink postname 的WordPress-get_permalink返回page_id,而不是%postname%永久链接设置中的错误 - Wordpress - get_permalink to return page_id instead of slug in %postname% permalink setting 如何在永久链接设置为“/%postname%/”的情况下从 URL 中删除类别库 - How to remove category base from URL with permalink set to “/%postname%/” 要在wordpress php中的URL永久链接中显示类别,子类别,子子类别和帖子名称 - To display category,sub-category,sub-sub categories and postname in url permalink in wordpress php
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM