Cau*_*tle 16 wordpress nginx http-status-code-404
我在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;
}
Run Code Online (Sandbox Code Playgroud)
小智 36
接受的答案将一切都通过index.php
.
这将打破某些脚本包含,wp-admin脚本就是其中之一.
location /blog/ {
index index.php;
try_files $uri $uri/ /blog/index.php?$args;
}
Run Code Online (Sandbox Code Playgroud)
Cau*_*tle 15
嗯...感谢您的所有评论和回答.但最后我使用这种方法来实现它
location /blog {
index index.php;
rewrite ^/blog/(.*)+$ /blog/index.php?$1; # it finally works
# return 200 $request_uri; # it is for inspect what $request_uri is
# try_files $uri $uri/ /blog/index.php$request_uri$is_args$args; # it gets 500 server error
}
Run Code Online (Sandbox Code Playgroud)
请指出当前设置是否有任何问题.谢谢!
我会建议以下内容,以捕获子文件夹/博客下的任何永久链接
location /blog {
index index.php;
try_files $uri $uri/ /blog/index.php?$args;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
27488 次 |
最近记录: |