Jake M asked:
My problem is urls within my PHP scripts are not resolving correctly. Ie, the domain name I am using in a PHP script doesn’t resolve back to the server when accessed from within the server.
For context; I have a php script that is generating a PDF (uses
mpdf library). The PDF is built from a HTML template that has images in it. The image urls are in the format
src="/images/foo.png". The PDF generation library complains that:
mPDF error: IMAGE Error (https://mywebsite.com/images/foo.png): Could not find image file
I know its an internal server domain resolution issue because if I place that above image url into my browser the image appears.
What do I need to configure on my Cent OS 6.8 VPS to resolve these urls internally? I have added an entry to
/etc/hosts but it’s still not resolving (maybe I need to restart some services on the server to enable the change?). My server is with GoDaddy and all of the below was already in the file. I just added
127.0.0.1 localhost.localdomain localhost mywebsite.com ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 XX.XX.XXX.222 mywebsite.com sXXX-XXX-XX-71.secureserver.net sXXX-XXX-XX-71 ip-XX-XX-XXX-222.ip.secureserver.net ip-XX-XX-XXX-222 XXX.XXX.XX.71 mywebsite.com
You need to place the correct IP address and hostname in
/etc/hosts and remove the wrong one.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.