如何提供静态文件
http://example.com/website/product.html
as
http://example.com/product
在nginx conf文件中
答案 0 :(得分:0)
可能有更好的方法来提供静态文件:使用CENTOS,NGINX 1.10.0 Ubuntu
•在您的区域记录中创建CNAME:例如static.example.com
•在您的NGINX域配置文件中(例如/ etc / nginx / sites-enabled / default),添加一个类似于以下内容的服务器块:
server {
listen 80;
listen [::]:80;
root /var/www/html;
index index.php;
server_name static.example.com;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
•重启NGINX服务和PHP:
$ sudo systemctl restart nginx.service
$ sudo systemctl restart php7.0-fpm.service
•调整所有静态文件的网址:例如http://static.example.com/js/my_javascript.js