[solved]how to access localhost website from local network

Problems with the Windows version of XAMPP, questions, comments, and anything related.

[solved]how to access localhost website from local network

Postby drasgan » 14. June 2012 16:30

I run a website on localhost XAMPP computer which is accessible from localhost computer by typing in the browser address bar:
http://mydomain.local
But it only works on the local XAMPP computer. I'd like to allow another computer in the same LAN to access the website. I've configured the other computer hosts file to contain line:
192.168.3.149 mydomain.local
where 192.168.3.149 is the XAMPP computer IP address. But after typing the http://mydomain.local on the other computer browser, after pressing enter, the address becomes: http://mydomain.local/xampp and some strange page opens. (by the way, this is the same page which would open on the localhost XAMPP computer after typing http://localhost/xampp in its browser address). So I would conclude that the other computer reaches the XAMPP computer, but for some reason, instead of going to the mydomain.local host, it goes to xampp default page.

So far, I have done this:

Changed I:\xampp\apache\conf\extra\httpd-xamp.conf file to contain this (see "Allow from" containing 192.168.3 - it should allow access from the whole subnet):
Code: Select all
# Close XAMPP sites here
<LocationMatch "^/(?i:(?:xampp|licenses|phpmyadmin|webalizer|server-status|server-info))">
    Order deny,allow
    Deny from all
    Allow from ::1 127.0.0.0/8 192.168.3
    ErrorDocument 403 /error/HTTP_XAMPP_FORBIDDEN.html.var
</LocationMatch>


On my XAMPP computer, I have the following configuration in I:\xampp\apache\conf\extra\httpd-vhosts.conf:
Code: Select all
NameVirtualHost mydomain.local:80
<VirtualHost mydomain.local:80>
    ServerAdmin postmaster@dummy-host2.localhost
    DocumentRoot "I:/xampp/htdocs/myphpapp"
    ServerName mydomain.local
    ServerAlias mydomain.local
    ErrorLog "logs/mydomain.local-error.log"
    CustomLog "logs/mydomain.local-access.log" combined

<Directory "I:/xampp/htdocs/myphpapp">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>


I don't know what else to check. Please help.
Last edited by drasgan on 15. June 2012 12:24, edited 2 times in total.
drasgan
 
Posts: 9
Joined: 29. August 2011 13:59

Re: how to access localhost website from local network

Postby JonB » 14. June 2012 18:23

See if this post helps - its a very close situation

8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: how to access localhost website from local network

Postby drasgan » 14. June 2012 21:00

Which post?
drasgan
 
Posts: 9
Joined: 29. August 2011 13:59

Re: how to access localhost website from local netw

Postby drasgan » 15. June 2012 10:54

I noticed the following entries in access.log, when trying to access XAMPP computer from another LAN computer:
Code: Select all
192.168.3.196 - - [15/Jun/2012:11:42:35 +0200] "GET / HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 6.0) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5"
192.168.3.196 - - [15/Jun/2012:11:42:35 +0200] "GET /xampp/ HTTP/1.1" 403 1332 "-" "Mozilla/5.0 (Windows NT 6.0) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5"

I think the problem is in the second line. Why is it redirecting from "/" to "/xampp" ??

Compare it to the correct example (when accessing from localhost):
Code: Select all
127.0.0.1 - - [15/Jun/2012:11:46:38 +0200] "GET /myphpapp..../.../... HTTP/1.1" 304 - "http://mydomain.local/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5"

In this second case, I am GETting the correct address.

Why apache treats the same web address differently from LAN computer and from localhost? Which configuration option is responsible?
drasgan
 
Posts: 9
Joined: 29. August 2011 13:59

Re: how to access localhost website from local netw

Postby JonB » 15. June 2012 12:10

this one:

viewtopic.php?f=16&t=50788


Good Luck
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: how to access localhost website from local netw

Postby drasgan » 15. June 2012 12:21

Thanks but as I mentioned in my first post, the other computer has already the "hosts" file correct. Otherwise, it wouldn't reach my XAMPP computer using the domain name.
drasgan
 
Posts: 9
Joined: 29. August 2011 13:59

Re: how to access localhost website from local netw

Postby Altrea » 15. June 2012 13:14

Hi drasgan,

In your VHost definition, please change the first two lines to
Code: Select all
NameVirtualHost *:80
<VirtualHost *:80>


Restart your Apache and try again to request.

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: how to access localhost website from local network

Postby drasgan » 15. June 2012 14:33

Thanks 100x, it worked!
drasgan
 
Posts: 9
Joined: 29. August 2011 13:59


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 114 guests