[英]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.