我有一个站点曾经位于文档根目录的根级别。我将它移动到新文档根目录中的子文件夹I。所有链接都是绝对的(/assets/styles.css、/folder/file.php)。我的子文件夹位于 example.com/sub/。有什么办法可以让 Nginx 将 /assets 重写为 example.com/sub/assets?
问问题
1190 次
1 回答
0
你应该在你的 nginx.conf 中有这样的东西
location /assets {
root /var/www/example.com/documentroot/;
...
}
它告诉 NginX 从该目录中获取“资产”。除非我弄错了,否则您应该简单地编辑“/var/www/example.com/documentroot/sub/”中的根文件夹。
或者,你在那里有一个完整的根:
location / {
root /var/www/example.com/documentroot/;
index index.php;
...
}
同样,您只需将“sub/”添加到“documentroot/”。
最后,如果您只想移动“资产”,请在 nginx.conf 中编辑或添加“位置/资产”配置节。
于 2012-07-09T00:38:48.870 回答