gpt4 book ai didi

wordpress - Nginx在子文件夹中重写(404)

转载 作者:行者123 更新时间:2023-12-03 14:29:48 27 4
gpt4 key购买 nike

我在NGINX服务器上有一个站点主机,该服务器以前可以正常工作,可以使用index.php删除nginx站点配置中的try_files

但是现在我要在其上添加一个博客,其URL为www.foo.com/blog,我可以访问该博客并使用index.php?p=

但是,一旦我在Nginx Helper www.foo.com/blog/2013/07/bar中使用了永久链接,就会得到404

server {
# don't forget to tell on which port this server listens
listen 80;

# listen on the www host
server_name foo.com;

# and redirect to the non-www host (declared below)
return 301 $scheme://www.ultra-case.com$request_uri;
}

server {
# listen 80 default_server deferred; # for Linux
# listen 80 default_server accept_filter=httpready; # for FreeBSD
listen 80;

# The host name to respond to
server_name www.foo.com;

# Path for static files
root /web/foo.com

#index file
index index.php;

#Specify a charset
charset utf-8;

# Custom 404 page
error_page 404 /404.html;

# Uri Rewrite

location /blog {
index index.php;
try_files $uri $uri/ /blog/index.php?$args;
}

location / {
autoindex on;
# This is cool because no php is touched for static content.
# include tihe "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}

# Include the component config parts for h5bp
include conf/h5bp.conf;
}

最佳答案

接受的答案通过index.php路由所有内容。
这将破坏某些脚本,其中wp-admin脚本就是其中之一。

您可以使用:

location /blog/ {
index index.php;
try_files $uri $uri/ /blog/index.php?$args;
}

关于wordpress - Nginx在子文件夹中重写(404),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17805576/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com