我正在使用在Ubuntu 12.10中运行的nginx 1.2.1
我已按照https://stackoverflow.com/a/7958540/80353
中的解决方案进行操作所以我的虚拟现在看起来像:
server {
listen 80;
server_name www.example.com;
return 301 http://example.com$request_uri;
}
server {
listen 80;
client_max_body_size 5M;
server_name example.com;
root /var/virtual/example.com/webroot;
include common.conf;
include php.conf;
}
不确定我做错了什么。
目前,每当我执行www.example.com/posts/123
时,我都会获得302 example.com
我期待example.com/posts/123
更新:
server {
listen 80;
server_name www.example.com;
rewrite ^(.*) http://example.com$1 permanent;
}
server {
listen 80;
client_max_body_size 5M;
server_name example.com;
root /var/virtual/example.com/webroot;
include common.conf;
include php.conf;
}
common.conf是:
index index.html;
location ~ /\.ht {
deny all;
}
cakephp.conf是:
include php.conf;
location / {
try_files $uri $uri/ /index.php?$uri&$args;
expires max;
access_log off;
}
php.conf是:
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
index index.php;