我需要在现有的WP网站上引入一些漂亮的网址:
/foo
应解释为
/index.php?page_id=5¶m=foo
我试过,在我的服务器块中:
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
# other fastcgi stuff ...
}
location / {
rewrite /foo /index.php?page_id=5¶m=foo last;
try_files $uri $uri/ /index.php?$args;
}
但是wordpress继续将我重定向(301):
/foo-another-post-title-with-same-prefix
我错在哪里以及如何调试? 谢谢
答案 0 :(得分:0)
location /foo {
rewrite ^ /index.php?page_id=5¶m=foo last;
}
应该做的工作:)
答案 1 :(得分:0)
基本永久链接是通过
获得的location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
在进行故障排除时,您可以enable rewrite_log:
rewrite_log on; # http block
然后从set loglevel到notice
error_log /var/log/nginx/error.log notice;