Don Smith
asked on
Problems using host file to redirect websites to local host for testing (setting test site to my ip)
Just inherited a large classic asp site. Customer wants to retain absolute urls back to same site (cites Google advantage, which I doubt), so I want to be able to test by redirecting the site to my local server using the host file. After MANY roadblocks, I now get a "403 forbidden" error. This is after fighting lots of localstart.asp problems. I guess there's something important I don't know about authentication. Has anyone ever done this using a vmware xp virtual machine hosted by Windows 7? Other ideas?
It seems that you have not set default page in web server. Can you access web site using http://website.com/pagename.asp ?
ASKER
There is a default page and it is in the defaults documents list. This site does start up fine from Dreamweaver, but of course jumps out to www-land on the absolute url's. Yes to your question.
H,
IE interpretes the hostfile on loading. Wat do you have in your C:\windows\system32\driver s\etc\host s file?
When you ping www.site.com does it respond and resolve your local VM?
Did you setup the host header on the VM to respond to www.site.com?
Did you ALSO setup the VM HOST FILE to respond to itself on the same IP?
-Hades666
IE interpretes the hostfile on loading. Wat do you have in your C:\windows\system32\driver
When you ping www.site.com does it respond and resolve your local VM?
Did you setup the host header on the VM to respond to www.site.com?
Did you ALSO setup the VM HOST FILE to respond to itself on the same IP?
-Hades666
ASKER
Here is my host file on the virtual xp machine:
# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# 127.0.0.1 localhost
127.0.0.1 www.restaker.com
127.0.0.1 restaker.com
Are you suggesting I need to change the windows 7 host machine's host file also? Windows 7 doesn't allow me to change the hosts file without changing a lot of permissions, which I'd rather avoid if not necessary.
restaker.com is the website, which is real, which I want to test on my local machine.
# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# 127.0.0.1 localhost
127.0.0.1 www.restaker.com
127.0.0.1 restaker.com
Are you suggesting I need to change the windows 7 host machine's host file also? Windows 7 doesn't allow me to change the hosts file without changing a lot of permissions, which I'd rather avoid if not necessary.
restaker.com is the website, which is real, which I want to test on my local machine.
on windows7 , START | Right click on NOTEPAD and chose RUN AS ADMINISTRATOR.
Then browse to C:\windows\system32\driver s\etc\host s and modify the file with
127.0.0.1 www.restaker.com
127.0.0.1 restaker.com
Your windows7 will now refresh it properly.
-Hades666
Then browse to C:\windows\system32\driver
127.0.0.1 www.restaker.com
127.0.0.1 restaker.com
Your windows7 will now refresh it properly.
-Hades666
ASKER
I made that change, but still getting the IE error "HTTP 403 Forbidden". Also, Firefox comes back with "Directory Listing Denied", even though I use no trailing "/".
To review: The issue is on my virtual (vmware) xp machine running under Windows 7. Dreamweaver 8 can launch the site ok with IE and Firefox, but when I try to go raw to www.restaker.com I still get the above errors.
I'm thinking this HAS to be an authentication issue. The site takes anonymous access, and windows Authentication is checked. I run on my own user account, which has admin privileges.
Any other suggestion? (thanks for your responses so far, btw)
To review: The issue is on my virtual (vmware) xp machine running under Windows 7. Dreamweaver 8 can launch the site ok with IE and Firefox, but when I try to go raw to www.restaker.com I still get the above errors.
I'm thinking this HAS to be an authentication issue. The site takes anonymous access, and windows Authentication is checked. I run on my own user account, which has admin privileges.
Any other suggestion? (thanks for your responses so far, btw)
Hi,
I understand the issue. You have a XP_VM Running on your Windows7 Host. When you browse through dreamweaver it loads. Ok, Were is dreamweaver installed? on Windows 7?
When you ping www.restaker.com from windows7, what IP does it resolve?
-Hades666
I understand the issue. You have a XP_VM Running on your Windows7 Host. When you browse through dreamweaver it loads. Ok, Were is dreamweaver installed? on Windows 7?
When you ping www.restaker.com from windows7, what IP does it resolve?
-Hades666
ASKER
Dreamweaver 8 is on the virtual box (xp). Not on Windows 7.
Ping to www.restaker.com from Windows 7 WITHOUT hosts entries: 208.68.104.123, and surfing to it works, too.
Ping to www.restaker.com from Windows 7 WITH hosts entries: 127.0.0.1, and surfing to it brings me to a "Welcome to IIS7" page, presumably because I have no default website set up for Windows 7.
Same ping results on the virtual xp machine, by the way.
Ping to www.restaker.com from Windows 7 WITHOUT hosts entries: 208.68.104.123, and surfing to it works, too.
Ping to www.restaker.com from Windows 7 WITH hosts entries: 127.0.0.1, and surfing to it brings me to a "Welcome to IIS7" page, presumably because I have no default website set up for Windows 7.
Same ping results on the virtual xp machine, by the way.
Hi,
That is the issue there.
Your entry needs to point to the XPVM IP. "127.0.0.1" is a reserved INTERNAL IP. So if you add www.restaker.com 127.0.0.1 to your local Host File, it will always look for IIS Services on that host. This is why 127.0.0.1 loads Welcome to IIS7 with the entry on windows7. This shows that you have IIS installed in a default configuration.
So, Open your XPVM, Click Start, RUN Type CMD, then type "ipconfig". This is your XPVM IP Address. It should be something like 192.168.*.* etc...
Then, as mentioned above, open Notepad as Administrator and add the www.restaker.com xp.vm.ipaddress.
Hades666
That is the issue there.
Your entry needs to point to the XPVM IP. "127.0.0.1" is a reserved INTERNAL IP. So if you add www.restaker.com 127.0.0.1 to your local Host File, it will always look for IIS Services on that host. This is why 127.0.0.1 loads Welcome to IIS7 with the entry on windows7. This shows that you have IIS installed in a default configuration.
So, Open your XPVM, Click Start, RUN Type CMD, then type "ipconfig". This is your XPVM IP Address. It should be something like 192.168.*.* etc...
Then, as mentioned above, open Notepad as Administrator and add the www.restaker.com xp.vm.ipaddress.
Hades666
ASKER
I did what you suggested (on both the host and the virtual box), and I still get the response I mentioned above:
>>I made that change, but still getting the IE error "HTTP 403 Forbidden".
>>Also, Firefox comes back with "Directory Listing Denied", even though I use no trailing "/".
Also, restarted both IE and Firefox. And stopped and started IIS on the virtual machine.
Just so I understand, are you saying that when redirecting locally on the virtual machine, the Windows 7 machine's IIS is involved? I wouldn't have thought so, but your suggestion implied that. In any event, I did both, but no change.
>>I made that change, but still getting the IE error "HTTP 403 Forbidden".
>>Also, Firefox comes back with "Directory Listing Denied", even though I use no trailing "/".
Also, restarted both IE and Firefox. And stopped and started IIS on the virtual machine.
Just so I understand, are you saying that when redirecting locally on the virtual machine, the Windows 7 machine's IIS is involved? I wouldn't have thought so, but your suggestion implied that. In any event, I did both, but no change.
Run ipconfig on the XP vm and provide the output please. There is something you are missing or i am not explaining properly.
Cheers,
Hades666
Cheers,
Hades666
ASKER
Here you are:
C:\Documents and Settings\dsmith>ipconfig
Windows IP Configuration
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . : Belkin
IP Address. . . . . . . . . . . . : 192.168.2.4
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.2.1
C:\Documents and Settings\dsmith>
By the way, I should have maybe mentioned this: I wondered about noise between the machines earlier, so I had my client, who has a pure XP machine to try the same redirect (had to walk him through the hosts change), and he got a similar result to mine.
C:\Documents and Settings\dsmith>ipconfig
Windows IP Configuration
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . : Belkin
IP Address. . . . . . . . . . . . : 192.168.2.4
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.2.1
C:\Documents and Settings\dsmith>
By the way, I should have maybe mentioned this: I wondered about noise between the machines earlier, so I had my client, who has a pure XP machine to try the same redirect (had to walk him through the hosts change), and he got a similar result to mine.
From the HOST Windows7, you can ping 192.168.2.4 right?
Is the the IP you add to www.restaker.com in the windows7 host file? If not, It should be.
-Hades666
Is the the IP you add to www.restaker.com in the windows7 host file? If not, It should be.
-Hades666
ASKER
Yes, and yes. Still fuzzy on why the windows 7 host file is involved - my ignorance.
Because you are browsing IIS on the XPVM. For windows7 to resolve the XPVM IIS, you need to bind it in the hostfile.
OK, so your Win7 host has www.restaker.com 192.168.2.4.
Does it load from IE on Win7?
On XPVM, ping www.restaker.com and paste the output here.
Cheers,
Hades666
OK, so your Win7 host has www.restaker.com 192.168.2.4.
Does it load from IE on Win7?
On XPVM, ping www.restaker.com and paste the output here.
Cheers,
Hades666
ASKER
1. In case this is unclear, both the local website and dreamweaver are on the XPVM. The need to redirect to the local site is also on the XPVM. From an application perspective, Windows 7 is not involved.
2. Yes, both hosts have 192.168.2.4 www.restaker.com. You don't mean to say in your first question that the hosts entry should have the site name first, then the local IP address, do you?
3. I get the same responses from IE and Firefox on both the W7 host machine and the XPVM. Before I fooled with the Win7 machine's hosts file, IE and Firefox (on the Win7 machine) both went normally to the real (remote) site.
Here's the XPVM ping:
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\dsmith>ping www.restaker.com
Pinging www.restaker.com [192.168.2.4] with 32 bytes of data:
Reply from 192.168.2.4: bytes=32 time<1ms TTL=128
Reply from 192.168.2.4: bytes=32 time=1ms TTL=128
Reply from 192.168.2.4: bytes=32 time=1ms TTL=128
Reply from 192.168.2.4: bytes=32 time<1ms TTL=128
Ping statistics for 192.168.2.4:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms
C:\Users\dsmith>
Hope this helps.
2. Yes, both hosts have 192.168.2.4 www.restaker.com. You don't mean to say in your first question that the hosts entry should have the site name first, then the local IP address, do you?
3. I get the same responses from IE and Firefox on both the W7 host machine and the XPVM. Before I fooled with the Win7 machine's hosts file, IE and Firefox (on the Win7 machine) both went normally to the real (remote) site.
Here's the XPVM ping:
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\dsmith>ping www.restaker.com
Pinging www.restaker.com [192.168.2.4] with 32 bytes of data:
Reply from 192.168.2.4: bytes=32 time<1ms TTL=128
Reply from 192.168.2.4: bytes=32 time=1ms TTL=128
Reply from 192.168.2.4: bytes=32 time=1ms TTL=128
Reply from 192.168.2.4: bytes=32 time<1ms TTL=128
Ping statistics for 192.168.2.4:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms
C:\Users\dsmith>
Hope this helps.
1. Yes, to use the local you need to modify your host file on ALL machines.
2. Typo... you are correct. 192.168.2.4 www.restaker.com
3. This is good, so you are seeing the same issue not and NOT resolving your production site.
SO, on the XPVM what does http://localhost resolve? What IIS host headers did you add to the site under IIS Manager?
What URL does dreamweaver load? Does it load with the HOST ENTRIES in place?
My guess is no ;)
-Hades666
2. Typo... you are correct. 192.168.2.4 www.restaker.com
3. This is good, so you are seeing the same issue not and NOT resolving your production site.
SO, on the XPVM what does http://localhost resolve? What IIS host headers did you add to the site under IIS Manager?
What URL does dreamweaver load? Does it load with the HOST ENTRIES in place?
My guess is no ;)
-Hades666
ASKER
On XPVM http://localhost returns "Directory Listing Denied". I don't see an ip address flash by.
"X-Powered-By: ASP.NET" is the only entry in Custom HTTP Headers. I didn't add that.
Dreamweaver loads "http:\\virtualxp\restaker\Index.asp
Don't understand "Does it load with the HOST ENTRIES in place?"
"X-Powered-By: ASP.NET" is the only entry in Custom HTTP Headers. I didn't add that.
Dreamweaver loads "http:\\virtualxp\restaker\Index.asp
Don't understand "Does it load with the HOST ENTRIES in place?"
Dreamweaver is loading http:\\virtualxp\restaker\Index.asp where restaker is a virtualpath to the main site. Going by what you provided virtualXP is the name of the machine.
If that is the case, then these should load.
http:\\localhost\restaker\Index.asp
http:\\www.restaker.com\restaker\Index.asp
The reason for directory listing denied is beacuse a default document is not enabled in the virtual path and directory listing is denied.
Now when i say the host entries in place, i mean 192.168.5.4 www.restaker.com is added to the hosts files.
Thse should load fine.
Hades666
If that is the case, then these should load.
http:\\localhost\restaker\Index.asp
http:\\www.restaker.com\restaker\Index.asp
The reason for directory listing denied is beacuse a default document is not enabled in the virtual path and directory listing is denied.
Now when i say the host entries in place, i mean 192.168.5.4 www.restaker.com is added to the hosts files.
Thse should load fine.
Hades666
ASKER
Not bad, hades, not bad. They work fine. Do I infer from this that to redirect via texts, the target site (at least its default page) needs to be actually IN the default website (i.e. Inetpub\wwwroot) and not in a (sub) virtual directory? This can make sense to me.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Got it. I work on several sites locally, so I use virtual directories a lot. I guess this means that without a lot of workarounds, you can only fake-redirect one website.
I really appreciate the time you've spent working on this. Will close this problem now with points, etc. If there are more problems once I move the site, I'll start a new problem.
Again, thanks a lot.
I really appreciate the time you've spent working on this. Will close this problem now with points, etc. If there are more problems once I move the site, I'll start a new problem.
Again, thanks a lot.
Well, if you are using virtual directories, you can use hosts entries plus a custom default page like such.
<%
If InStr(lcase(Request.Server Variables( "SERVER_NA ME")),"www.domain.com") > 0 Then
Response.AddHeader "Location","http://virtualxp/domain"
ElseIf InStr(lcase(Request.Server Variables( "SERVER_NA ME")),"www.company.com") > 0 Then
Response.Redirect("http://virtualxp/company")
ElseIf InStr(lcase(Request.Server Variables( "SERVER_NA ME")),"www.testsite.com") > 0 Then
Response.AddHeader "Location","http://virtualxp/testsite/"
Else
'load up whatever is displayed by the subdomain itself or redirect elsewhere
End If
%>
Cheers, Hades666
<%
If InStr(lcase(Request.Server
Response.AddHeader "Location","http://virtualxp/domain"
ElseIf InStr(lcase(Request.Server
Response.Redirect("http://virtualxp/company")
ElseIf InStr(lcase(Request.Server
Response.AddHeader "Location","http://virtualxp/testsite/"
Else
'load up whatever is displayed by the subdomain itself or redirect elsewhere
End If
%>
Cheers, Hades666