根据http://wiki.nginx.org/HttpCoreModule 我正在尝试让服务器搜索特定目录中的文件。 即:http://exemple.com/sitemap.xml将查看rootFolder / sitemaps / specificname-sitemap.xml
我补充说:
location /sitemap.xml {
alias /sitemaps/specificname-sitemap.xml;
}
但它不起作用。我错过了什么?
编辑: 我的完整内容是:
server {
listen 80; ## listen for ipv4; this line is default and implied
root /var/www/exemple/public;
index index.html index.htm index.php;
server_name exemple.com;
location /sitemap.xml {
alias /sitemaps/cs-sitemap.xml;
}
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
答案 0 :(得分:0)
找到解决方案:
location /sitemap.xml {
try_files $uri /sitemaps/specificName-sitemap.xml;
}