3

I am trying to create a virtual host in xampp windows 7.

#NameVirtualHost *:80
<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/project/Trunk/xyz"
    ServerName xyz.local
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
</VirtualHost>

host

127.0.0.1       localhost
127.0.0.1       xyz.local

Edit 1: httpd -t -D DUMP_VHOSTS result is given below

VirtualHost configuration: *:80 is a NameVirtualHost default server abcd (C:/xampp/apache/conf/extra/httpd-vhosts.conf:45) port 80 namevhost abcd (C:/xampp/apache/conf/extra/httpd-vhosts.conf:45) port 80 namevhost localhost (C:/xampp/apache/conf/extra/httpd-vhosts.conf:49) port 80 namevhost xyz.local (C:/xampp/apache/conf/extra/httpd-vhosts.conf:53) *:443 www.example.com (C:/xampp/apache/conf/extra/httpd-ssl.conf:102)

Edit 2: Attachment - website not found error

enter image description here

Calling http://xyz.local/ shows the website not found error. But if I configure entire thing with only xyz (not .local in the string xyz.local) it is working fine after calling http://xyz/. I want it as http://xyz.local/. How can I achieve this?

Kiren S
  • 3,037
  • 7
  • 41
  • 69
  • That looks like it should work to me - have you restarted Apache after making the change? – CD001 Jul 01 '15 at 10:04
  • As far as I know, you can only omit `NameVirtualHost` in Apache/2.4. What's your version? – Álvaro González Jul 01 '15 at 10:29
  • @ÁlvaroG.Vicario - just checked the Apache 2.2 httpd-vhosts.conf on my machine and it's commented out there; don't know about earlier versions though ;) – CD001 Jul 01 '15 at 10:31
  • @CD001 To be precise, you need [2.3.11 or greater](http://httpd.apache.org/docs/2.4/en/mod/core.html#namevirtualhost). Otherwise, it needs to be set. Seriously. – Álvaro González Jul 01 '15 at 10:41
  • Apache/2.4.12 (Win32) OpenSSL/1.0.1l PHP/5.6.8 – Kiren S Jul 01 '15 at 10:42
  • @CD001 Yes I restarted the Apache – Kiren S Jul 01 '15 at 10:44
  • @ÁlvaroG.Vicario I already set it and tried but same result – Kiren S Jul 01 '15 at 10:46
  • @ÁlvaroG.Vicario : ah, my bad, I'm running 2.4; saw `# ` in the comments in httpd-vhosts.conf and assumed I was still running 2.2 ... must have updated my dev box at some point and just ported in the old 2.2 hosts file ;) – CD001 Jul 01 '15 at 10:48
  • @KirenSiva - Why? It isn't required for 2.4. Whatever, can you edit the question and copy the output of this command? `httpd -t -D DUMP_VHOSTS` – Álvaro González Jul 01 '15 at 10:56
  • @ÁlvaroG.Vicario please see my edit – Kiren S Jul 01 '15 at 11:08
  • @KirenSiva - Your actual settings do not match your *.conf files... Is it possible you're just editing the wrong files? (That's surprisingly easy to do with these third-party bundles.) In any case, even those other settings should work. When you say "website not found error" you mean the browser's error page and not some text rendered by your application, don't you? – Álvaro González Jul 01 '15 at 11:39
  • @ÁlvaroG.Vicario it is not the text rendered by your application.Hope I am editing the correct files. Because `http://xyz/` is working fine. – Kiren S Jul 01 '15 at 11:47
  • 2
    Just seen your second edit. You're using a proxy and you're getting a plain IP resolution problem! You probably need to configure your browser so it doesn't use a proxy for the `.local` top-level domain. It has nothing to do with Apache I'm afraid. – Álvaro González Jul 01 '15 at 11:49
  • 1
    Oh Microsoft Forefront Threat Management Gateway ... that's an obsolete router/firewall/web cache ... that could be hijacking your DNS requests – CD001 Jul 01 '15 at 11:49
  • Finally solved.Thank you both for the clue. I changed the browser proxy settings to bypass the proxy server for the request xyz* and it is worked as expected :) – Kiren S Jul 01 '15 at 12:00
  • 1
    I'm voting to close this question as off-topic because it's down to a browser configuration error. –  Jul 02 '15 at 04:02

0 Answers0