.htaccess question please

Discussion in 'HTML' started by BusyGuy, Sep 21, 2006.

  1. BusyGuy

    BusyGuy Guest

    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.
    BusyGuy, Sep 21, 2006
    #1
    1. Advertising

  2. 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/
    Jukka K. Korpela, Sep 21, 2006
    #2
    1. Advertising

  3. BusyGuy

    BusyGuy Guest

    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.
    BusyGuy, Sep 22, 2006
    #3
  4. 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/
    Jukka K. Korpela, Sep 22, 2006
    #4
  5. BusyGuy

    BusyGuy Guest

    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 pissing 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 pissed off with
    the webmaster, only with a determined surfer who tries to evade the
    block.
    BusyGuy, Sep 23, 2006
    #5
  6. 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.
    Alan J. Flavell, Sep 23, 2006
    #6
  7. 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/
    Jukka K. Korpela, Sep 23, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Samuël van Laere

    Charset - htaccess question

    Samuël van Laere, Jul 9, 2003, in forum: HTML
    Replies:
    9
    Views:
    3,556
    T. Audry Glamour
    Jul 9, 2003
  2. Bart van den Burg

    .htaccess question

    Bart van den Burg, Sep 15, 2003, in forum: HTML
    Replies:
    3
    Views:
    466
    Bart van den Burg
    Sep 16, 2003
  3. mentalguy2004

    htaccess question...

    mentalguy2004, Aug 24, 2004, in forum: HTML
    Replies:
    3
    Views:
    410
    lostinspace
    Aug 24, 2004
  4. KK
    Replies:
    2
    Views:
    556
    Big Brian
    Oct 14, 2003
  5. Mark Shapiro

    htaccess file help please

    Mark Shapiro, Mar 4, 2011, in forum: HTML
    Replies:
    10
    Views:
    834
    Denis McMahon
    Mar 8, 2011
Loading...

Share This Page