问题
I am using nginx 1.2.1 running in Ubuntu 12.10
I have followed the solution in https://stackoverflow.com/a/7958540/80353
So my vhosts now look like:
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;
}
Not sure what I did wrong.
Currently, whenever I do a www.example.com/posts/123
, I get 302 to example.com
I was expecting example.com/posts/123
UPDATE:
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 is:
index index.html;
location ~ /\.ht {
deny all;
}
cakephp.conf is:
include php.conf;
location / {
try_files $uri $uri/ /index.php?$uri&$args;
expires max;
access_log off;
}
php.conf is:
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
index index.php;
来源:https://stackoverflow.com/questions/22093091/how-to-convert-www-example-com-posts-123-to-example-com-posts-123