Difference between specifying IP in host file vs using IP directly - windows

Is there any difference between the following when a intranet URL in accessed in IE
Add an entry in drivers/etc/host file for a name and IP
vs
Use IP directly
e.g. it works with the following link if I have a host entry as (XYZ 10.0.10.200)
http://XYZ/SiteDirectory/ABC/Default.aspx
but when I tried to use IP instead of name
http://10.0.10.200/SiteDirectory/ABC/Default.aspx
It gives me 404 not found error

Yes, there's a difference.
The web server is using HTTP/1.1 and "shared virtual hosting". When the client connects it sends an additional Host: header which contains the hostname part of the URL that the user supplied.
The web server looks at the header to find out which virtual host's data to serve.
In this case, the web server is configured to recognise and serve content from the "XYZ" domain, but doesn't know about any domain called 10.0.10.200

Smells like the webserver is using virtual hosts, so that it serves different pages if the client went to "www.foo.com" or "www.bar.com", even though they have the same IP-address.

As far as I can see there should be no difference. With a host name the order is hosts file before DNS so it should be used.
Is there another line in the host file with the same hostname?
What happens when you do a tacert? (trace route)

Related

How to access a device connected in local network with hostname?

I tried accessing a webpage in a server within the local network with the host name of the device followed by its folder path and the name of the file(it is a basic php file) in first system.It worked as expected.
But when i tried the same in second system connected in the same local network ,i couldn't access it with the host name but i could access the page with the IP address of the server.
And ofcourse the second system's DNS was configured as the router which is the DNS for my local network.
Is there any additional configurations that i need to do for accessing the server with host name?
If you are using windows edit the file :\windows\system32\drivers\etc\hosts
If you are using linux the file is /etc/hosts
and add a line using the sintax already on the file
IPadress hostname
for example
192.168.10.100 www.mywebserver.com
save and done.

Windows - etc/hosts configuration not working

I made this entry in my C:\windows\system32\drivers\etc\hosts file:
convert2mp3.net convert2mp3.com
so that my browser always calls convert2mp3.net instead of convert2mp3.com if i accidentially call convert2mp3.com
But it does not work. I also flushed the DNS cache by executing ipconfig /flushdns in the CMD. I also tried to use another browser but still no redirect.
What am I doing wrong?
The /etc/host file is used to force the resolution of a domain to a specified IP Address. Your line is missing the ip Address help for win7
It should be:
127.0.0.1 mywebsite
You cannot change DNS names like that, especially not in an HTTP context.
So the problem is you sometimes type a .com address in your browser where the site you want to go to actually is at the same address - only ending in ".net".
Even if you could change the hosts file to let the .com address point to the .net server's address, the request is likely to return an error, because their server isn't configured to handle requests to the .com address, which your browser will still send as a host header.
So create a bookmark in your browser and click that, instead of typing DNS addresses yourself if you're making that mistake that often.

Hosts file how do I allow only one domain name

I'm setting up an iMAC in a store. They want to have the browser open to their website and restrict access so people can't use the computer to browse any other site. I see many discussions online but no actual code sample. Can you please write out the exact lines of code that I need to add to the hosts file and its location on a new iMAC with OS X.
You can achieve this by catching all web traffic and routing it to the IP address of the site you want to limit access to.
For example: If the website IP was 10.0.0.1
10.0.0.1 .com
10.0.0.1 .info
10.0.0.1 .org
(You can keep adding rows for each TLD (.com, .net etc) that you wish to block.
Any http requests sent from the machine would then try to resolve on that host.
This should prevent other websites from resolving but the one you require.

why does my domain name immediately switch to showing its ip address once page loads?

I just registered a new domain name and set it to point to an AWS EC2 instance. When I enter the domain name, it loads fine, but then as soon as the page loads, the browser address text is updated to show the ip address (replaces the domain name). I cloned this EC2 from another server where this was not happening and where I hadn't done any non-default Apache2 server settings other than URL shortening to remove .html and .php file extensions. Any ideas what could be happening here? I tried it on multiple computers and multiple browsers.
Sounds like your webserver is issuing a redirect after the first connection is made, and the redirect is pointed to the IP adress of the server. You can get more information to confirm this by using Chrome Network Console.
In this case I had mistakenly updated the DNS record for forwarding rather than for the # tag, so it was forwarding to the site.

How to find database host url in joomla

i have a website with Joomla 2.5.4, in the configuration file the DB host is coded as localhost. i know the DB name, username, password to access. But not the URL to access the Host. is that Possible to get the information without logging in to C PANEL etc..
in some situations my client fails to give me the url to access DB, if iopen the configuration file, there it says LOCALHOST.
Is there any other way to find out?
If the configuration.php has localhost then it should be the same as the website/the ip address of the website. Remember 'localhost' is just a synonym for the current computer.
I'm not sure why you would want the URL though.
If you're writing a software extension for Joomla! you don't need the database details you can just get the database object from the framework, eg. $db = JFactory::getDBO();
If you writing a PHP script external to Joomla! you can just use localhost in your connection code e.g..
$mysqli_connection = new MySQLi('localhost', 'user', 'pass', 'db');
To check for errors in the connection you would the check the value in $mysqli_connection->[connect_error][2]
If you want to do a remote connection then the websites address will generally do if the configuration states localhost (obviously if it doesn't have local host or an equivalent then the value will be the database servers address), but you will also need to setup the remote access through cPanel.
I'm afaid you cannot find this information in other way than through your webhost, at least not to my knowledge.
localhost is the most usual way, but there are most likely other host adresses like: mysql.yourhost.com or by ip: 123.456.456.7
I also faced same problem. I left the host name as 'localhost' when the files are in the file server. Then it works fine for me. If its not working fine for you,just put your domain name instead of localhost (or) otherwise file hosting service provider needs to provide the details of host name when you signup.

Resources