Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Nginx-重写/到子文件夹_Php_Nginx - Fatal编程技术网

Php Nginx-重写/到子文件夹

Php Nginx-重写/到子文件夹,php,nginx,Php,Nginx,我有一个站点,它通常位于文档根的根级别。我正在将其移动到新文档根目录中的子文件夹I。所有链接都是绝对链接(/assets/styles.css、/folder/file.php)。我的子文件夹位于example.com/sub/。有没有办法让Nginx重写/assets到example.com/sub/assets?您的Nginx.conf中应该有类似的内容 location /assets { root /var/www/example.com/documentro

我有一个站点,它通常位于文档根的根级别。我正在将其移动到新文档根目录中的子文件夹I。所有链接都是绝对链接(/assets/styles.css、/folder/file.php)。我的子文件夹位于example.com/sub/。有没有办法让Nginx重写/assets到example.com/sub/assets?

您的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中编辑或添加“位置/资产”配置节