我在nginx服務器上有一個站點主機。以前使用try_files
可以正常工作,以便在nginx站點配置中刪除index.php
。Nginx重寫子文件夾
但現在我要添加一個博客,其中的網址將是www.foo.com/blog
,我可以訪問博客並使用index.php?p =確定。
但一旦我用漂亮的永久鏈接與Nginx的助手,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;
}
'根/ WEB/foo.com'分號失蹤 –
@MohammadAbuShady UM ...對於我的錯誤感到抱歉,我想隱藏真實的服務器主機名和文件位置,這只是錯誤。 – Cauliturtle