3

I'm using get_headers() to see if sites are up or not, and it's all fine, but when I try and check my local sites, I get a 'response timed out' error. The 'local' URLs are not on a 'real' domain, but are something like:

http://steve-emachine/WEBSITES_PHP/Sites/HOGSMILL/index.php

...where 'steve-emachine' is my machine name. Is there any way to use get_headers() on this kind of URL? The URLs work fine in a browser, so it's obviously just my ignorance of how HTTP works that is the problem.

konsolenfreddy
  • 9,551
  • 1
  • 25
  • 36
Hogsmill
  • 1,574
  • 13
  • 21
  • Really strange! A just tried it and if I have no virtual host defined for given address, the server reports `server reached MaxClients setting` error in it's log. – Peter Krejci Jan 08 '12 at 21:37
  • get_headers Inconsistency : http://stackoverflow.com/questions/12781795/get-headers-inconsistency – Baba Oct 08 '12 at 15:35

2 Answers2

0

Make sure you use the full address with the http:// prefixed to it in your php code. Like this

http://local.mysite.com

the hosts file is in /etc/hosts on linux and looks something like 127.0.0.1 localhost 127.0.1.1 drew-ThinkPad-T410 127.0.0.1 local.mysite.com

0

Though for me, the url formats you mentioned is working, make sure that you have entry in hosts file of your operating system for that particular domain which you are using (steve-emachine in your case). To use get_headers() on local site, you can do this:

  1. Add virtual-host on your server, with some name like local.mysite.com
  2. Make host entry in your operating system for that domain 127.0.0.1 local.mysite.com
  3. Restart your server
  4. use $url = http://local.mysite.com in get_headers(), it will work fine.
Rajat Garg
  • 355
  • 1
  • 2
  • 11