今天我用nginx安装了wordpress。问题是,我搞不清楚,有些页面将按预期提供,而另一些页面将作为下载。如果我下载它们,内容就是sama as索引。wordpress根文件夹中的php。我试图找出“正常”页面和其他缺陷页面之间的一些差异,但找不到任何人。
有趣的是,如果我给有问题的页面另一个永久链接(例如…/funktionen->../features),页面将被正确服务。如果切换回旧的永久链接,页面将被作为下载。
这是我的nginx配置:
#redirect
# http://www.termin2go.com and
# http://termin2go.com
# to
# https://www.termin2go.com
server {
listen 80;
server_name termin2go.com www.termin2go.com;
rewrite ^(.*) https://www.termin2go.com$1 permanent;
}
# redirect
# https://termin2go.com
# to
# https://www.termin2go.com
server {
listen 443 ssl;
server_name termin2go.com;
rewrite ^(.*) https://www.termin2go.com$1 permanent;
}
server {
listen 443 ssl;
server_name www.termin2go.com;
ssl_certificate /etc/ssl/private/www.termin2go.com.crt;
ssl_certificate_key /etc/ssl/private/www.termin2go.com.key;
access_log /var/log/nginx/termin2go.com.log;
error_log /var/log/nginx/termin2go.com_error.log;
set $root_path \'/var/www/wordpress\';
root $root_path;
charset utf-8;
client_max_body_size 7M;
# DEFAULT INDEX
index index.php;
# configure prerender for snapshot generation
location / {
try_files $uri $uri/ /index.php?$args @prerender;
}
location ~ /(\\.|wp-config.php|liesmich.html|readme.html) {
return 444;
}
# REWRITES
location ~ ^/(\\d+)/$ {
return 301 /?p=$1;
}
# fix whitespace in url bug
if ($request_uri ~ " ") { return 444; }
# redirect google bot to prerender for ajax content (AngularJS)
location @prerender {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_intercept_errors on;
set $prerender 0;
if ($http_user_agent ~* "googlebot|yahoo|bingbot|baiduspider|yandex|yeti|yodaobot|gigabot|ia_archiver|facebookexternalhit|twitterbot|developers\\.google\\.com") {
set $prerender 1;
}
if ($args ~ "_escaped_fragment_|prerender=1") {
set $prerender 1;
}
if ($http_user_agent ~ "Prerender") {
set $prerender 0;
}
if ($prerender = 1) {
rewrite .* /$scheme://$host$request_uri break;
proxy_pass http://127.0.0.1:4000;
}
if ($prerender = 0) {
rewrite .* /index.php break;
}
}
# cache static files one month
location ~* \\.(css|cur|js|jpe?g|gif|htc|ico|png|html|xml|otf|ttf|eot|woff|svg)$ {
expires 31d;
add_header Pragma "public";
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
# cache static files 30 days
location ~* \\.(css|cur|js|jpe?g|gif|htc|ico|png|html|xml|otf|ttf|eot|woff|svg)$ {
expires 31d;
add_header Pragma "public";
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \\.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\\.php)(/.+)$;
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
# prevent nginx from serving dotfiles (.htaccess, .svn, .git, etc.)
location ~ /\\. {
deny all;
access_log off;
log_not_found off;
}
}