I am using the hosts
file for blocking websites, and when we try to open that website the browser shows some default message, but I need to display my own message.
Is there any possibility for displaying a user-defined message?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityI am using the hosts
file for blocking websites, and when we try to open that website the browser shows some default message, but I need to display my own message.
Is there any possibility for displaying a user-defined message?
Run a web-server on your local machine on the usual port (80) and set a custom error page
In your hosts file use 127.0.0.1 as the address for blocked domains
Update:
If you have Perl installed, you can use something like this (start it from a command prompt)
#!/usr/bin/perl
use strict;
use warnings;
use HTTP::Daemon;
use HTTP::Status;
my $d = HTTP::Daemon->new(LocalPort => 80);
while (my $c = $d->accept) {
while (my $r = $c->get_request) {
$c->send_file_response("./blocked.html");
}
$c->close;
undef($c);
}
Other scripting languages are available. Batteries not included.
hosts
file is the wrong tool for this job … – JdeBP Dec 7 '11 at 23:39