我有my-domain.com和prod.my-domain.com,我为两者创建了以下配置设置。
server {
listen 80;
server_name prod.my-domain.com;
location / {
root /usr/share/nginx/html/;
index index.php index.html index.htm;
}
location /prod{
autoindex on;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/index/html/prod/;
}
error_page 500 502 503 504 /50x.html;
location = /50.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_intercept_errors on;
error_page 404 /path/to/404.htm;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server{
listen 80;
server_name my-domain.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
# redirect server error pages to the static page /50x.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$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_intercept_errors on;
error_page 404 /path/to/404.htm;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
但是,无论我输入哪个网址,我都会将my-domain.com
的所有文件都存储起来。
我希望在访问时看到root /usr/share/nginx/index/html/prod/
的内容
prod.my-domain.com
但是,我需要根/usr/share/nginx/index/html/