我有一個在WordPress中運行網站的nginx服務器(1.4.1)。它會自動將www.mysite.com重定向到mysite.com,沒有任何特定的規則。如果最初輸入的話,我希望它停止並保留www。Nginx Running Wordpress將www重定向到非www www
您能否檢查一下我的配置並告訴我可能是什麼原因?如果我測試它的圖像文件,不會發生重定向,但PHP文件它...
server {
listen 80;
server_name www.mysite.com mysite.com;
access_log /logs/mysite.com/access.log;
error_log /logs/mysite.com/error.log crit;
root /home/sites/mysite.com/;
location/{
index index.php;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_intercept_errors off;
}
}
fastcgi_params:
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
就是這樣。謝謝!這甚至沒有發生在我身上。我確信這是我的nginx配置的問題。非常感激! –