我的一个网站有一个奇怪的情况,仍在AWS中开发.我在t2.micro上使用了HHVM 3.6.6-1.amzn1.x86_64的Nginx 1.9.9.它不公开.
我在域的根目录中有一个自定义编写的网站,我在/ blog目录中有wordpress,而wordpress管理员在/ blog / wp-admin中.自定义站点包含各种文件,包括index.PHP. wordpress在blog目录中有index.PHP和各种其他东西,wp-admin也使用index.PHP.
我可以加载自定义网站,它完全有效. wordpresss管理员完全有效. wordpress博客主屏幕/故事列表完全有效.问题是,当我点击任何博客文章链接来查看它时,它会显示自定义网站主页索引.所以,换句话说
http://www.example.com/index.PHP - custom website works
http://www.example.com/blog/index.PHP - blog index works
http://www.example.com/blog/2015/storyname - story load doesn't work with permalink %postname% regardless of text in post name - http://www.example.com/index.PHP loads
http://www.example.com/blog/2015/?p=96 - story load works
http://www.example.com/blog/wp-admin/ - admin works
当我点击故事链接时,我得到相同的页面内容,就好像我点击了http://www.example.com/index.php,除了图像没有加载,因为他们已经完成了相对的URL
http://www.example.com/blog/2015/storyname
当我加载站点根目录/index.PHP时,我得到了以下调试头(请参阅下面的配置,了解它们是如何生成的)
Z_LOCATION: PHP MAIN
URI: /index.PHP
Z_DOCUMENT_ROOT: /var/www/hr
Z_FASTCGI_SCRIPT_NAME: /index.PHP
Z_REQUEST_FILENAME: /var/www/hr/index.PHP
当我加载/ wp-admin /我得到这些标题
Z_LOCATION: PHP MAIN
URI: /blog/wp-admin/index.PHP
Z_DOCUMENT_ROOT: /var/www/hr
Z_FASTCGI_SCRIPT_NAME: /blog/wp-admin/index.PHP
Z_REQUEST_FILENAME: /var/www/hr/blog/wp-admin/index.PHP
当我加载博客主页/blog/index.PHP时,我得到了这些标题
Z_LOCATION: PHP MAIN
URI: /blog/index.PHP
Z_DOCUMENT_ROOT: /var/www/hr
Z_FASTCGI_SCRIPT_NAME: /blog/index.PHP
Z_REQUEST_FILENAME: /var/www/hr/blog/index.PHP
当我尝试加载此URL http://www.example.com/blog/2015/storyname时,我得到以下标题. Z_REQUEST_FILENAME(上面)显示正在加载的错误URL.
Z_LOCATION: PHP MAIN
URI: /index.PHP
Z_DOCUMENT_ROOT: /var/www/hr
Z_FASTCGI_SCRIPT_NAME: /index.PHP
Z_REQUEST_FILENAME: /var/www/hr/index.PHP
我不知道为什么当我点击该URL时它会尝试加载站点根index.PHP.线索:
>将wordpress永久链接结构从%postname%更改为?p = 123
解决了这个问题
>其他永久链接结构都没有任何帮助
为什么这只是查看博客文章的问题????我想知道这是否与try_files有关?
hhvm错误日志中没有任何内容,Nginx错误日志中没有任何内容.当我请求最后一个URL时,访问日志显示以下内容
(IP removed) - - [10/Jan/2016:08:22:19 +0000] "GET /blog/2015/storyname HTTP/1.1" 200 4424 "http://www.example.com/blog/" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0" "-" "0.050"
这是我的Nginx站点配置.我没有包含主要的Nginx.conf,因为我认为它不相关. NB我已经更新了这项工作的工作代码.
server {
server_name www.example.com;
root /var/www/hr;
access_log /var/log/Nginx/hr.access.log main;
# Default location to serve
location / {
try_files $uri $uri/ /blog/index.PHP?$args;
add_header Z_LOCATION "hr_root"; add_header URI $uri; # DEBUG
}
location ~* \.(jpg|jpeg|png|gif|css|js)${
log_not_found off; access_log off;
add_header Z_LOCATION "STATIC RESOURCES REGEX"; add_header URI $uri; # DEBUG
}
# Send HipHop and PHP requests to HHVM
location ~ \.(hh|PHP)${
fastcgi_keep_conn on;
fastcgi_intercept_errors on;
fastcgi_pass PHP;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# DEBUGGING
add_header Z_LOCATION "PHP MAIN"; add_header URI $uri;
add_header Z_DOCUMENT_ROOT "$document_root"; add_header Z_FASTCGI_SCRIPT_NAME "$fastcgi_script_name";
add_header Z_REQUEST_FILENAME "$request_filename";
}
}
# Forward non-www requests to www
server {
listen 0;
server_name example.com;
return 302 http://www.example.com$request_uri;
}
任何想法,想法或帮助表示赞赏.对我来说,这是一个相当卷曲的,但我怀疑修复它将是一个简单的改变.
一种选择是使WorkPress成为默认值:
location / {
try_files $uri $uri/ /blog/index.PHP?$args;
...
}
或者,添加另一个位置块以仅处理以/ blog / …开头的URI:
location /blog {
try_files $uri $uri/ /blog/index.PHP?$args;
...
}