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
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.
Add ProxyPreserveHost On
with your Apache virtual host ProxyPass directives.