duangengruan2144 2014-02-06 10:27
浏览 195
已采纳

Laravel使用服务器IP加载文件和链接URL,而不是访问请求的URL

My Laravel site is hosted on a IP to which I am redirecting a URL. The problem is that index page loads but all the css, js and images are being loaded from the IP and not the URL. Even all the internal links are going to that IP. Is laravel creating URLS based only on host IP instead of taking Request URL into acount.

Eg: Suppose my host IP for website is 1.2.3.4/xyz and my URL to access it is sub.abc.com/xyz Then If I load sub.abc.com/xyz page opens but the js css and images are coming from 1.2.3.4/xyz instead of sub.abc.com/xyz And links are going to 1.2.3.4/xyz/contact instead of abc.com/xyz/contact

I am using laravel's methods to make these URLs

Note: xyz folder is being proxypassed to another ip

  • 写回答

2条回答 默认 最新

  • dousi4900 2014-02-15 07:44
    关注

    Ok from Laravel IRC chat I got to know that problem is something with the server configuration.

    Thinking over all the configuration I guess this is what happening and causing problem

    We type sub.abc.com/xyz which should go to abc.com-->sub-->xyz folder So now Request URL is sub.abc.com/xyz

    But in this folder there are no website files instead a Request(proxypassed) is made to another location 1.2.3.4/xyz which should look for a folder xyz on 1.2.3.4 So now the Request URL becomes 1.2.3.4/xyz

    So now when it comes to Laravel at 1.2.3.4/xyz, the Request URL is 1.2.3.4/xyz and not sub.abc.com/xyz so all the files and links from laravel are returned with a URL of 1.2.3.4/xyz

    Hence now the page that comes to the browser has 1.2.3.4/xyz links instead of requested sub.abc.com/xyz Now you may say that if whatever I said is true then why dont domain and corresponding IP breaks in all websites.

    For which I will say that

    Lets say you type xyz.com which points to 4.5.6.7 IP. here again website gets request URL as 4.5.6.7 and sends the file at same link But then again this IP 4.5.6.7 is mapped back to xyz.com and served to browser so brwser gets correct link.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 写uniapp时遇到的问题
  • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
  • ¥15 找一个网络防御专家,外包的
  • ¥100 能不能让两张不同的图片md5值一样,(有尝)
  • ¥15 informer代码训练自己的数据集,改参数怎么改
  • ¥15 请看一下,学校实验要求,我需要具体代码
  • ¥50 pc微信3.6.0.18不能登陆 有偿解决问题
  • ¥20 MATLAB绘制两隐函数曲面的交线
  • ¥15 求TYPCE母转母转接头24PIN线路板图
  • ¥100 国外网络搭建,有偿交流