我有三个子域名,如m.xyz.com,test.xyz.com,prod.xyz.com,main.xyz.com,如果我重定向我的子域,那么它会自动找到该网站的默认文件夹路径。我想将所有子域重定向到不同的文件夹位置。我在centos中使用nginx服务器,即使创建了四个单独的.conf文件,它也会重定向到默认位置。 .conf文件代码如下: -
服务器{
listen 80;
server_name m.xyz.com www.m.xyz.com;
root /usr/share/nginx/html/folder1/location1/;
index index.php index.html index.htm;
location / {
#try_files $uri $uri/ =404;
try_files $uri $uri.html $uri/ @extensionless-php;
index index.html index.htm index.php;
}
# redirect server error pages to the static page /50x.html
#
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
location ~ \.php$ {
try_files $uri =404;
#fastcgi_pass unix:/var/run/xyz/xyz-php-fpm.sock;
fastcgi_pass 192.168.1.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# rewrites
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
charset utf-8;
#access_log /var/log/nginx/log/host.access.log main;
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} `