我正在使用在 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;
}
不知道我做错了什么。
目前,每当我做 a 时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;