服务器绑定两个域名www.domain.com,m.domian.com
静态文件在/wwwroot/wwwroot/default/staitc/下,静态文件地址都是相对地址,导致m.domian.com无法访问静态文件
/static/images/2017/a.jpg
正常http://www.domain.com/static/images/2017/a.jpg
404错误http://m.domain.com/static/images/2017/a.jpg
我想用nginx转发,但是不成功
server
{
listen 80;
server_name www.domain.com;
index index.php index.html;
root /wwwroot/wwwroot/default;
error_page 404 /404.html;
error_page 502 /502.html;
include enable-php-56.conf;
}
server
{
listen 80;
server_name m.domain.com;
index index.php index.html;
root /wwwroot/wwwroot/default/m;
location /static/ {
proxy_pass http://www.domain.com/static/;
}
}
/wwwroot/wwwroot/default/m/下只有
/wwwroot/wwwroot/default/m/index.php
/wwwroot/wwwroot/default/m//template/
访问http://m.domain.com/static/返回404
在/wwwroot/wwwroot/default/m/目录下创建/static/目录,访问http://m.domain.com/static/就能正常转发到http://www.domain.com/static/
问题1:nginx转发只能是静态文件转静态文件吗?
问题2:只能转发/m/目录下存在的文件吗?
问题3:我要怎配置才能正常转发?