I cannot post the following in forum, but I can here. It's happened many times and it's a bit annoying to be honest, it says the code I posted is wrong, there is no code here, but it also does it when I try to comment some things.

http://textuploader.com/aowvp

Recommended Answers

All 5 Replies

The error.

The code snippet in your post is formatted incorrectly. Please use the Code button in the editor toolbar when posting whitespace-sensitive text or curly braces.

A hosts file should only have one redirect IP on each line, but I've seen some people put two like so...

127.0.0.1 somedomain.com aliasname   92.103.3.45 domain.org 

It would need to be fixed to look like so...

127.0.0.1 somedomain.com aliasname
92.103.3.45 domain.org

So here is an example of one I seen recently...

# Copyright (c) 1993-2009 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

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost


127.0.0.1 localhost me
127.0.0.1 www.affiliatewindow.com/

127.0.0.1     activate.adobe.com     #adobe phone home fro dreamweaver

127.0.0.1     static.eplayer.performgroup.co.uk  perf
127.0.0.1     eplayer.performgroup.com  127.0.0.1     bactivate.adobe.com
127.0.0.1     www.performgroup.com      
# 127.0.0.1     www.javascript.com
# 127.0.0.1   www.yahoo.com

After it is parsed I would want it to look like this...

127.0.0.1     localhost me
127.0.0.1     www.affiliatewindow.com
127.0.0.1     activate.adobe.com
127.0.0.1     static.eplayer.performgroup.co.uk  perf
127.0.0.1     eplayer.performgroup.com
127.0.0.1     bactivate.adobe.com
127.0.0.1     www.performgroup.com

Only one IP per line
Can have multiple aliases after domain
No trailing whitespace
Comments removed
Slashes removed
Neat and tidy

Worked for me. Copied, pasted, select all, then pressed tab. (or perhaps it depends on the forum.) What forum did you post in?

commented: Thank you kndly +0
A hosts file should only have one redirect IP on each line, but I've seen some people put two like so...

127.0.0.1 somedomain.com aliasname   92.103.3.45 domain.org 

It would need to be fixed to look like so...

127.0.0.1 somedomain.com aliasname
92.103.3.45 domain.org

So here is an example of one I seen recently...

# Copyright (c) 1993-2009 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

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost


127.0.0.1 localhost me
127.0.0.1 www.affiliatewindow.com/

127.0.0.1     activate.adobe.com     #adobe phone home fro dreamweaver

127.0.0.1     static.eplayer.performgroup.co.uk  perf
127.0.0.1     eplayer.performgroup.com  127.0.0.1     bactivate.adobe.com
127.0.0.1     www.performgroup.com      
# 127.0.0.1     www.javascript.com
# 127.0.0.1   www.yahoo.com

After it is parsed I would want it to look like this...


127.0.0.1     localhost me
127.0.0.1     www.affiliatewindow.com
127.0.0.1     activate.adobe.com
127.0.0.1     static.eplayer.performgroup.co.uk  perf
127.0.0.1     eplayer.performgroup.com
127.0.0.1     bactivate.adobe.com
127.0.0.1     www.performgroup.com

Only one IP per line
Can have multiple aliases after domain
No trailing whitespace
Comments removed
Slashes removed
Neat and tidy

@pritaeas I never knew about pressing TAB, thanks.
That's what it looks like when I do that.

@rproffitt, I'm not so sure about that, the article does not mention hosts file, and I'd be a little wary of using 0.0.0.0 in it as I have Sockets listening on any connection, so if data gets redirected to it, I'd be afraid those sockets might pick it up.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.