嗨,伙计们,我希望我的所有 NON-WWW url 请求永久移动并重写为 WWW,我已经尝试在这些以及 Nginx no-www 到 www 和 www 到 no-www上遵循现有的解决方案, 但它仍然没有工作我。
例如,我希望 example.com 或 example.com/* 重写为 www.example.com 或 www.example.com/*
我正在使用 nginx 和 memcache 运行 PHP-FPM
下面是我的配置
server {
listen 80;
server_name abc.com;
return 301 http://www.example.com$request_uri;
}
server {
listen 80;
server_name www.example.com;
root /srv/www/abc;
index index.php index.html index.htm;
.......
}
以下是我的卷曲回复
neel:~ nilesh$ curl -I http://example.com
HTTP/1.1 200 OK
Server: nginx/1.4.6 (Ubuntu)
Date: Fri, 21 Aug 2015 19:00:54 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: PHP/5.5.9-1ubuntu4.11
X-Drupal-Cache: HIT
Etag: "1440178291-0"
Content-Language: en
X-Generator: Drupal 7 (http://drupal.org)
Link: <http://example.com/>; rel="canonical",<http://example.com/>; rel="shortlink"
Cache-Control: public, max-age=1800
Last-Modified: Fri, 21 Aug 2015 17:31:31 +0000
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Vary: Cookie
Vary: Accept-Encoding