Windows: How to use hosts file with path? - hosts-file

This works:
127.0.0.1 www.somesite.com
But not this:
127.0.0.1/somepath/www www.mysite.com
What am I doing wrong? Is it possible to map a full path like this? If not, what is the easiest way to accomplish what I want to do here?

The simple answer is that you can't use the hosts file to redirect to specific URLs. It can only be used to map hostnames to IP addresses.

Related

I need to know, how can I add many URLs to the windows hosts file?

I want to block DNS requests in my computer such as login.live.com, fs.windows.com, …, etc.
Basically, I'll change the settings
But I want to know How I add many URLs to the windows hosts file.
(I have many URLs to block, about 1000 URLs in text file)
The hosts file contains hostnames, not URLs.
Run Notepad As Administrator and edit C:\Windows\System32\Drivers\etc\hosts
Each line you add should be an IP address (e.g. a dummy one or 127.0.0.1 foor the loopback IP), followed by whitespace (space(s), tab(s)), followed by a hostname.
This will indeed prevent lookups in DNS for A records.
But are you sure this is how you want to do it?
There may be better methods, like using a filtering proxy for example.

Possible to create a temporary host entry on Heroku

Is it somehow possible to edit /etc/hosts on Heroku , through the buildpack or otherwise?
I have a couple of dev sites that I need to connect to that don't have DNS entries, so I need to add a couple entries to /etc/hosts.
Thanks
I am pretty sure that's not possible. However, why can't you just specify the IP of whatever host you're trying to connect to, instead of specifying a host name? Also, if you absolutely must, I suppose you could create entries in a DNS server of a domain of your own (say: mydomain.com), and then specify myhost.mydomain.com.

I need a browser-compatible proxy that can do this

I am looking for a proxy server that can do this.
If I set my firefox settings to that proxy, and go to google, then it should "proxy" to google normally. Just a normal proxy.
But I want there to be rules. I want to redirect anything that matches http://google.com/... to http://12.34.56.78/...
I was thinking about writing one but to be honest there has to be something to do this already built.
Fiddler should do what you want. If you type into the black box at the bottom "overridehost google.com 12.34.56.78" it should redirect any Google requests to the specified IP.
Not a proxy per se, but what about editing your local host file? If you are a Windows user just go to "C:\WINDOWS\system32\drivers\etc" and edit the "hosts" file accordingly. Eg. add a new line:
12.34.56.78 google.com
I know the use is limited, because you cannot make more complex redirects. However it might be sufficient for your problem. Good luck! (on linux/unix the file is often located in /etc/hosts).
If you want a better solution, it would be helpful to give us your OS.

Send Host header when accessing IP address in Firefox

This isn't really a programming question but more about programming and testing tools.
Is there a way to get Firefox to send the header
Host: mydomain.com
when accessing a page at
http://ip.address.goes.here/
so that Apache can route it to the correct VirtualHost?
You can add the host name and ip-address to your hosts file.
Have you tried the Modify Headers Firefox extension?
If you are creating a site and wish to map the host header to an IP (perhaps your local dev box) for testing purposes, then you should consider editing the hosts file instead.
Just setup an entry in the hosts file. Always worked for me :)
I guess you could use the TamperData extension to manually add it each time.

Map 192.168.0.10 to 127.0.0.1 on windows

I need to access a SVN repository from home, that runs under the IP 192.168.0.10 in the work network.
I can establish a SSH tunnel to my localhost.
Now I have to map 192.168.0.10 in a way, that instead 127.0.0.1 is accessed.
Does anybody know a way to do this under Windows?
TortoiseSVN allows you to relocate your repository
http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-relocate.html#tsvn-dug-relocate-dia-1:
If your repository has for some reason changed it's location (IP/URL). Maybe you're even stuck and can't commit and you don't want to checkout your working copy again from the new location and to move all your changed data back into the new working copy, TortoiseSVN → Relocate is the command you are looking for. It basically does very little: it scans all entries files in the .svn folder and changes the URL of the entries to the new value.
Or you can use svn command:
svn switch --relocate From_URL To_URL
When you're at work, edit your HOSTS file to have svn = 192.168.0.10; when you're at home, edit it to have svn = 127.0.0.1, and then access it, in both by using 'svn' as the server name.
Alternatively, use the "svn switch --relocate" command to change the repository location when you need to.
Can you reference the DNS name instead? You can override the IP address for a DNS name in your hosts file (C:\windows\system32\drivers\etc\hosts).
I'm not sure that's possible at all. What you could do would be to reference a DNS name instead. You can change the IP the DNS name points to using your hosts file.
edit your hosts file located at %SystemRoot%\system32\drivers\etc\
As I understand the question is that you have a subversion repository checked out on a laptop (or some other computer) that you checked out at work using the ip address 192.168.0.10, and now you're at home and want to use it.
Personally I wouldn't try any fancy network reordering (or modifying the hosts file) but just use the SSH tunnel to check out a fresh copy of the repository on the machine again. So that you'll be checking the source out from the 127.0.0.1 address. Then if you need to move changes over you could use patches between the two checked out copies. Granted it's not the most ideal solution but it will get you going quickly without messing about too much.
Though a better solution would be to convince work to allow access to the repository (with proper passwords, authentication, SSL etc) using a nicer method, say apache with dav_svn/webdav.
If they don't go for that then try and get them to provide a VPN so that you can continue to work with the repository using the work IP address.
Why don't you just access svn via 127.0.0.1? Surely this would be a better solution?
You're faced with several issues here, if I understand correctly. There's only one way you can make this work, that is to have your home machine have an address of 192.168.0.10. Then, you specify the ssh local address with 192.168.0.10 instead of 127.0.0.1.
The remote ssh connection will also by 192.168.0.10.
E.g., ssh -l work_user -L 192.168.0.10:svn:192.168.0.10:svn work_ssh_host
This syntax is possible with OpenSSH.
This is all if I understand your situation correctly.
A more elegant solution is to use OpenVPN, and route connections over the VPN.
I think I have had the same situation before, I will have to find what the exact configuration though.
You can start by looking at PuTTY Portable, it supports SSH and you can "redirect" a local IP to a remote IP.
As far as I can remember, when you run PuTTY you can:
First specify you local address and port (this will be where you will be pointing your SVN client, e.g. Tortoise)
Then go to Connection->SSH->Tunnels-> specify your source port to redirect from (same as above), then specify the destination IP and port and click add
I think that should be it, it has been a while since I have done it.

Resources