Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > .htaccess question please

Reply
Thread Tools

.htaccess question please

 
 
BusyGuy
Guest
Posts: n/a
 
      09-21-2006
Folks, sorry to ask a newbie question.

Let's say I have two directories, each of which will contain an index
file. Site visitors are, at present, routed to one of these when they
click the relevant link on other pages.

I would like to place a .htaccess file and have it inspect the IP
address of the visitor. If that IP address falls within certain ranges
it will route the visitor to one of the above directories. If not, it
will direct to the other.

I would appreciate a hint to the correct code please.
 
Reply With Quote
 
 
 
 
Jukka K. Korpela
Guest
Posts: n/a
 
      09-21-2006
BusyGuy wrote:

> Folks, sorry to ask a newbie question.


It's not a newbie question, really. You are trying to make things difficult
in an advanced way.

> I would like to place a .htaccess file and have it inspect the IP
> address of the visitor. If that IP address falls within certain ranges
> it will route the visitor to one of the above directories.


What problem do you expect to solve with such an approach? The odds are
about 99 against 0 that you are trying to solve a wrong problem and end up
with _creating_ a problem.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

 
Reply With Quote
 
 
 
 
BusyGuy
Guest
Posts: n/a
 
      09-22-2006
In article <QXCQg.17306$>, Jukka K.
Korpela <> wrote:

> BusyGuy wrote:
>
> > Folks, sorry to ask a newbie question.

>
> It's not a newbie question, really. You are trying to make things difficult
> in an advanced way.
>
> > I would like to place a .htaccess file and have it inspect the IP
> > address of the visitor. If that IP address falls within certain ranges
> > it will route the visitor to one of the above directories.

>
> What problem do you expect to solve with such an approach? The odds are
> about 99 against 0 that you are trying to solve a wrong problem and end up
> with _creating_ a problem.


I want to direct any visitors from one specific country to a specific
page. All others can go to an alternative page. I would certainly
welcome an easier way to do it.
 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      09-22-2006
BusyGuy wrote:

> I want to direct any visitors from one specific country to a specific
> page.


That's what I suspected. So you _are_ solving the wrong problem.

You have no way of knowing what country I am from, for any definition for
being from a particular country. In particular, you cannot tell it from my
IP address, especially not when I am travelling abroad. Trying to guess the
country from an IP range is simply nonsensical.

Besides, people often actually mean language when they say "country".

So think again. _If_ you really have some special content for people who are
from Borduria (the proverbial country, you know), simply put a link to such
content on your main page. Such as "Special prices apply in Borduria",
making this expression a link. Problem solved.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

 
Reply With Quote
 
BusyGuy
Guest
Posts: n/a
 
      09-23-2006
In article <qrYQg.18098$>, Jukka K.
Korpela <> wrote:

> BusyGuy wrote:
>
> > I want to direct any visitors from one specific country to a specific
> > page.

>
> That's what I suspected. So you _are_ solving the wrong problem.
>
> You have no way of knowing what country I am from, for any definition for
> being from a particular country. In particular, you cannot tell it from my
> IP address, especially not when I am travelling abroad. Trying to guess the
> country from an IP range is simply nonsensical.
>
> Besides, people often actually mean language when they say "country".
>
> So think again. _If_ you really have some special content for people who are
> from Borduria (the proverbial country, you know), simply put a link to such
> content on your main page. Such as "Special prices apply in Borduria",
> making this expression a link. Problem solved.


Thanks very much, Jukka, I appreciate your reply.

Unfortunately, it doesn't help me and I truly hope you are a little bit
incorrect.

I did a search and found myself here
<http://software77.net/cgi-bin/ip-country/geo-ip.pl> but I also notice
these

<http://www.ip2location.com/> (which can pinpoint beyond country, down
to city)

and many others.

I did mean "country" as opposed to "language."

I want to deny access to a particular page for all visitors coming from
a particular country. Visitors from all other countries can have
access. It's a question of complying with a court order granting
suppression of information to a particular country.

I realise I can't stop determined people (who might use an anonymizing
service, for example) so I know it's not going to be 100% but I want to
do what I can.

Here is a hypothetical and fictional analog: imagine if a webmaster
wanted to avoid ****ing off the Chinese authorities by denying access
to a particular news page if the visitor is coming from China. I think
if some steps are taken, the authorities will not be ****ed off with
the webmaster, only with a determined surfer who tries to evade the
block.
 
Reply With Quote
 
Alan J. Flavell
Guest
Posts: n/a
 
      09-23-2006
On Sat, 23 Sep 2006, BusyGuy wrote:

> In article <qrYQg.18098$>, Jukka K.
> Korpela <> wrote:

....
> > So think again. _If_ you really have some special content for
> > people who are from Borduria (the proverbial country, you know),
> > simply put a link to such content on your main page. Such as
> > "Special prices apply in Borduria", making this expression a link.
> > Problem solved.

>
> Thanks very much, Jukka, I appreciate your reply.
>
> Unfortunately, it doesn't help me and I truly hope you are a little
> bit incorrect.


No, it's quite true what Jukka wrote.

> I did a search and found myself here
> <http://software77.net/cgi-bin/ip-country/geo-ip.pl> but I also notice
> these
>
> <http://www.ip2location.com/> (which can pinpoint beyond country, down
> to city)


Well yes - in favourable cases. But there are enough cases where it
won't do what was wanted, to make it impractical for real use. It says
I'm located in London, which is wrong. I'd say giving a wrong answer
is worse than admitting that the information simply isn't available.

> I want to deny access to a particular page for all visitors coming
> from a particular country. Visitors from all other countries can
> have access. It's a question of complying with a court order
> granting suppression of information to a particular country.


That might be different! Presumably now it's not so much a question
of actually working (in the technical sense), but of doing whatever
the court says you have to do. I don't think this newsgroup is really
a good place for getting legal advice, though, which I'm certainly not
qualified to give.

> I realise I can't stop determined people (who might use an
> anonymizing service, for example) so I know it's not going to be
> 100% but I want to do what I can.


That's not the only problem - some users will fall foul of your
acess-blocking measures through no fault of their own.

A friend works for a company whose IP numbers are all in Canada,
regardless of where they are geographically.

For a while, my ISP was routing traffic via Germany, and Google was
addressing me in German as a consequence. You can imagine how happy I
would be if someone had decided to block access from all "German"
users.

And so on.
 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      09-23-2006
Alan J. Flavell wrote:

>> I did a search and found myself here
>> <http://software77.net/cgi-bin/ip-country/geo-ip.pl> but I also
>> notice these
>>
>> <http://www.ip2location.com/> (which can pinpoint beyond country,
>> down to city)

>
> Well yes - in favourable cases. But there are enough cases where it
> won't do what was wanted, to make it impractical for real use. It says
> I'm located in London, which is wrong. I'd say giving a wrong answer
> is worse than admitting that the information simply isn't available.


The former of the services tells about 147.243.3.83 for example: "Country
Not Found".
Actually their FAQ warns about problems with multinational organizations.

That's more reasonable than giving wrong information, but it also raises the
question what should be done in that case, assuming that someone is forcing
you to prevent access from a particular country.

>> I want to deny access to a particular page for all visitors coming
>> from a particular country. Visitors from all other countries can
>> have access. It's a question of complying with a court order
>> granting suppression of information to a particular country.

>
> That might be different! Presumably now it's not so much a question
> of actually working (in the technical sense), but of doing whatever
> the court says you have to do.


I'm afraid the court order is very vague. Lawyers tend understand IT issues
even much less than IE people understand legal issues.

Anyway, denying access by the country of the _visitor_ is quite different
from denying access by the country of the _computer_. I'm pretty sure the
court didn't understand that.

What might help the OP avoid prison and bankruptcy is a _reasonable effort_
to do what the court might be guessed to have meant. (I'm not saying "best
effort", since nobody could afford best effort in a case like this.) Using
the IP to country mapping services and treating unknown country as one that
needs to be exluded might do that, when combined with .htaccess access
control by IP address. For the technicalities, the server documentation
would need to be consulted, which probably means something like
http://httpd.apache.org/docs/1.3/howto/auth.html
That means you would use deny directives, instead of trying any redirection.
You would "want" to exclude, not to send visitors to a particular page. The
denial could be accompanied with an error message (using the ErrorDocument
directive), i.e. a document that explains the situation to people who try to
access the page but are banned according to their IP. This would be in
accordance with the spirit of Internet protocols, but it could be construed
as a way of telling banned people how to avoid the banning, since to be
informative at all, you would need to reveal something about the banning
criteria. And as long as a prospective user knows that the IP is the
problem, he can circumvent the banning rather easily (though most people
would have to ask a friend to help there).

This will cost money and time, and it will exclude visitors that are not
from the country to be excluded. If my survival depended on a business where
such things need to be done, I'd try and find some other way to earn my
living. Such a court order indicates both lack of understanding how the
Internet works and willingness to control communication in a manner in which
it cannot be controlled, so who knows what they'll throw at you next week?

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please please please help this guy with his open source java app casioculture@gmail.com Java 4 05-05-2005 08:24 AM
Console profile for Windows app in VC++ - PLEASE PLEASE PLEASE HELP! MuZZy C++ 7 01-07-2005 08:40 PM
Computer problems please please please help Nick Computer Support 0 06-04-2004 08:49 PM
HELP! HELP! PLEASE, PLEASE, PLEASE tpg comcntr Computer Support 11 02-15-2004 06:22 PM
please help... ...me learn C++ please please please :) KK C++ 2 10-14-2003 02:08 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57