我试图设置我的nginx服务器块,以便我的域名www.domain.com被重定向到domain.com。 我的DNS设置:
A @ 111.111.111.111
CNAME * domain.com.
和nginx /etc/nginx/sites-available/wordpress
server {
listen 80;
server_name www.domain.com;
rewrite ^(.*) http://domain.com$1 permanent;
}
server {
listen 80;
server_name domain.com;
root /var/www/wordpress;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/html;
}
# pass the PHP scripts to FastCGI server listening on the php-fpm socket
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
当我重新启动nginx时,我从浏览器This web page has a redirect loop
收到错误。
我尝试了Nginx no-www to www and www to no-www的解决方案,但问题仍然存在。
我刚检查了错误日志/var/log/nginx/error.log
:
2015/04/20 14:33:32 [error] 16136#0: *17 client intended to send too large body: 1059663 bytes, client: 86.26.239.246, server: domain.com, request: "POST /wp-admin/async-upload.php HTTP/1.1", host: "www.domain.com", referrer: "http://www.domain.com/wp-admin/upload.php"
2015/04/21 04:42:19 [emerg] 19177#0: unknown directive "listen 80" in /etc/nginx/sites-enabled/wordpress:17
2015/04/21 04:47:08 [alert] 19262#0: *52 open socket #19 left in connection 6
2015/04/21 04:47:08 [alert] 19262#0: *53 open socket #22 left in connection 13
2015/04/21 04:47:08 [alert] 19262#0: aborting
/var/log/nginx/access.log
:
31.221.76.18 - - [21/Apr/2015:05:21:55 -0400] "GET / HTTP/1.1" 301 5 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36"
31.221.76.18 - - [21/Apr/2015:05:21:55 -0400] "GET / HTTP/1.1" 301 184 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36"
31.221.76.18 - - [21/Apr/2015:05:21:55 -0400] "GET / HTTP/1.1" 301 5 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36"
31.221.76.18 - - [21/Apr/2015:05:21:55 -0400] "GET / HTTP/1.1" 301 184 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36"
31.221.76.18 - - [21/Apr/2015:05:21:55 -0400] "GET / HTTP/1.1" 301 5 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36"
31.221.76.18 - - [21/Apr/2015:05:21:55 -0400] "GET / HTTP/1.1" 301 184 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36"
答案 0 :(得分:2)
Wordpress本身会将您重定向到设置中指定的域。
检查您是否使用** www。** domain.com配置了它