I'm trying to set up my development instances so that I can fake some urls that I own. My website has a number of url's and depending on the one you visit my site will act differently based on the domain..
ive edited my C:\WINDOWS\system32\drivers\etc\hosts File to contain something like below
127.0.0.1 localhost
127.0.0.1 SomeDomain.com
127.0.0.1 MyDomain.com
Now if I visit localhost everything works fine but when i try visit SomeDomain.com or MyDomain.com it produces couple different messages depending on browsers
Firefox - "Bad Request (Invalid Hostname)"
Chrome - Asked for a username/password and just hitting on (not entering anything) products same result as firefox
IE6- "The page cannot be displayed"
any ideas?
Your HOSTS file looks good. Also try adding the www version of each one, e.g.:
127.0.0.1 localhost
127.0.0.1 SomeDomain.com
127.0.0.1 www.SomeDomain.com
etc
However, the problem is probably the setup of the web server. If you're using IIS, the problem probably is that you haven't set up host headers correctly.
Related
In the office, we have already setup a redirect in the DNS to push .dev back to the localhost. The issue is when I am not in the office this does not work. I edited my host file for the websites but as I add more in the future I would prefer to not have to edit my host file.
Is there a way, within my computer, that I can force the TLD of .dev to always go back to my localhost?
I realize I may have to find a way to do this on my router so that the DNS is resolved.
Example:
- Local IIS
-- Website A (with a Host Name Binding of website-a.dev)
-- Website B (with a Host Name Binding of website-b.dev)
When I open a browser on my local box and type in website-a.dev, it should loop back to my local IIS and pull this website. Same thing for website-b.dev, of course, going to the other website. Now I know if at work we have setup the DNS to allow for this but I want to know if this can be done at home, where I do not have direct access to the DNS.
I know I can just put into my host file
127.0.0.1 website-a.dev
But I want a catch all for .Dev to go back to 127.0.0.1
Take a look at:
https://superuser.com/questions/135595/using-wildcards-in-names-in-windows-hosts-file
It explains that using Acrylic allows you to use wildcards and acts just like your host file.
I am having the following /etc/hosts file :
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.10.139/azc clientdomain.com www.clientdomain.com
80.230.215.84 home_server
The first, second and fourth line are working normally. However the third isn't. I tried to look for "invisible characters" and rewrote the whole line without copy-pasting anything, but the clientdomain.com query in my browser or via ping still brings me to my client's IP address.
Am I not allowed to use paths at all in my hosts file, just sheer IP addresses?
If I take out the /azc bit, the redirection does happens correctly.
I don't manage to have it working through .htaccess redirections either...
I was actually trying to redirect a domain name to a specific folder on my server.
I finally discovered (Doh!!) that Apache has a dedicated feature for this called VirtualHost.
This post explains very well how to set one.
I hope this helps.
I have a localhost set up on my Windows 7 computer for developing a website. When I accidentally spelled GoDaddy wrong and typed goodaddy.com into Chrome and hit enter it displayed my localhost site. It didn't redirect me. The address bar still said goodaddy.com. When I viewed the source of the page it was just the source of my localhost site but the address bar still displayed view-source:goodaddy.com
I tried ctrl+f5 to refresh it, I also tried navigating to goodaddy.com on a private browsing window in Chrome and it still displayed my localhost site. Then I tried it in Firefox and Safari, and they are also displaying the localhost site while keeping goodaddy.com in the address bar.
According to WhoIs information this is a registered domain name. And when I navigate to it from a different computer it just says 'Oops! Google Chrome could not connect to goodaddy.com'
So why are all the browsers on my computer treating this domain a if it was localhost instead of a domain that it cannot connect to like it is? I don't understand at all.
Edit: Also if I typed a nonsensical domain that definitely does not exist (example: jkdkfs.com) Chrome properly just says 'Oop! Google Chrome could not connect to jkdkfs.com' instead of showing me my localhost site. How did this one domain get mapped to my localhost site across all browsers?!
I get the same thing. The domain appears to be registered by Moniker DNS (www.moniker.com) to go to 127.0.0.1. See there - http://whoisrequest.org/whois/goodaddy.com
Why? Who knows :)
Other SO thread(s) on the subject - .com domain registered to 127.0.0.1
(You can skip directly to the question, but the context is on the background section.)
Technical Context
Windows 8
IIS 7
Background:
As several others, I work with IIS and from time to time I need to set up a local version of a site. Now, in setting up different sites, it is quite common to just assign them different ports so that they don't overlap. So you could have your site A at port 80, your site B at port 81 and so on.
Now, I want to setup the bindings so that I am able to have several sites under port 80 and with the header host distinction I can at the same time give meaningful URLs to these sites.
An option to do this is with adding entries to your hosts file, such as:
127.0.0.1 siteA.com
127.0.0.1 siteB.com
And with this, you should be able to browse to siteA.com or siteB.com and have that working locally.
But I want to take one more step, as localhost is already set up to match 127.0.0.1, so:
Question:
I had set up the IIS bindings as:
site host header port
siteA siteA.localhost 80
siteB siteB.localhost 80
And I expected that I would be able to browse to http://siteA.localhost/ and http://siteB.localhost/ and get my sites.
However, when I browse, it seems that my requests never reach IIS, and the address is not resolved.
Why isn't that working?
Update:
I have chosen chue x's answer because he explained why this doesn't work. For those that may follow my same path, you may think "well, I could just add *.localhost in the hosts file and it should be done." or even switch to *.local or *.localdev.com or something of that sort.
That, however, doesn't work: Wildcards in a Windows hosts file
As chue x pointed out, our only approach right now is to keep adding entries to the hosts file or, how they explain in the linked question, to use another DNS server.
Your hosts file needs to match your IIS bindings, which have to match the url browser.
So if your hosts file looks like:
127.0.0.1 siteA.localhost
127.0.0.1 siteB.localhost
Your IIS bindings need to be:
site host header port
siteA siteA.localhost 80
siteB siteB.localhost 80
Finally, from the local machine, you need to browse to:
http://siteA.localhost
EDIT - If you are trying to do the above without adding the hosts entries for siteA and siteB, it won't work. DNS won't find it. So for example, what happens if you try to browse to "foo.stackoverflow.com" - the request will fail even though "stackoverflow.com" is a known address.
To be more specific, I have a website called koyn. Here's the domain http://koyn.net . The website is hosted on my computer for testing purposes. I set up port forwarding and made the domain name point to my computer. Everything works fine because when I give the link out to people they can see my website fine, but here's my problem. When I visit my own visit on my computer on my network it directs me to my router settings. I have to type
http://localhost
in my address bar to access my website. I don't want to type localhost I want to access my website with koyn.net like everyone else. How can I do this? Thanks in advance :D!
If you are on windows box you need to edit the hosts file, so when ever you type koyn.net it will reroute to localhost.
I am assuming you have removed your port forwardig. Have you tried cleaning out your browser cache? Another option, assuming you are on a Windows machine is to flush your DNS with the following command:
ipconfig /flushdns
Editing Your Hosts File
Windows default location of host file: C:\Windows\System32\drivers\etc
Open it by notepad as administrator
All operating systems will have a hosts file like my example:
127.0.0.1 localhost
123.45.67.89 www.example.com
#98.76.54.32 www.anotherexample.com
More: https://www.youtube.com/watch?v=7e2MmyPvnhs
after save and flush your dns by command:
ipconfig /flushdns