Welcome to HostingForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

redirect german traffic with mod rewrite

 
   Web Hosting Problem Solving Community! (Home) -> Apache RSS
Next:  Mail Server for a Noob  
Author Message
user2480

External


Since: Sep 19, 2003
Posts: 5



(Msg. 1) Posted: Wed Jan 07, 2004 3:11 pm
Post subject: redirect german traffic with mod rewrite
Archived from groups: alt>apache>configuration (more info?)

Hello,

I am wondering how those big sites like google redirect specific
internet traffic. Is it possible to create a rewrite rool containing the
german, austrian and swiz ip adresses and shift this traffic a german site?

The only thing I found is this:
RewriteCond %{REMOTE_ADDR} =nnn.nnn.nnn.nnn

But this goes only for one IP adress and not for a complete range.

Does anybody know how to do that?

Thanx for any help on that,

Merlin

 >> Stay informed about: redirect german traffic with mod rewrite 
Back to top
Login to vote
mfuhr

External


Since: Nov 17, 2003
Posts: 44



(Msg. 2) Posted: Wed Jan 07, 2004 3:11 pm
Post subject: Re: redirect german traffic with mod rewrite [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Merlin <news.letters.RemoveThis@web.de> writes:

 > I am wondering how those big sites like google redirect specific
 > internet traffic. Is it possible to create a rewrite rool containing the
 > german, austrian and swiz ip adresses and shift this traffic a german site?

What's the purpose of this redirect? Is the user's country important,
or is it really the user's language that matters? If the latter, then
have a look at the Content Negotiation documentation:

<a style='text-decoration: underline;' href="http://httpd.apache.org/docs-2.0/content-negotiation.html" target="_blank">http://httpd.apache.org/docs-2.0/content-negotiation.html</a>
<a style='text-decoration: underline;' href="http://httpd.apache.org/docs/content-negotiation.html" target="_blank">http://httpd.apache.org/docs/content-negotiation.html</a>

 > The only thing I found is this:
 > RewriteCond %{REMOTE_ADDR} =nnn.nnn.nnn.nnn
 >
 > But this goes only for one IP adress and not for a complete range.
 >
 > Does anybody know how to do that?

You could omit the "=" and use a regular expression. The URL
Rewriting Guide has examples:

<a style='text-decoration: underline;' href="http://httpd.apache.org/docs-2.0/misc/rewriteguide.html" target="_blank">http://httpd.apache.org/docs-2.0/misc/rewriteguide.html</a>
<a style='text-decoration: underline;' href="http://httpd.apache.org/docs/misc/rewriteguide.html" target="_blank">http://httpd.apache.org/docs/misc/rewriteguide.html</a>

You could also use a module like mod_geoip to map the IP address
to a country and then make decisions based on the country:

<a style='text-decoration: underline;' href="http://www.maxmind.com/app/mod_geoip" target="_blank">http://www.maxmind.com/app/mod_geoip</a>

Note: there's no way to guarantee what country a user is in by
examining the user's IP address. The organization that owns the
IP address might have international operations, or the user's real
IP address might be hidden by a firewall or proxy.

--
Michael Fuhr
<a style='text-decoration: underline;' href="http://www.fuhr.org/~mfuhr/" target="_blank">http://www.fuhr.org/~mfuhr/</a><!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: redirect german traffic with mod rewrite 
Back to top
Login to vote
user2480

External


Since: Sep 19, 2003
Posts: 5



(Msg. 3) Posted: Thu Jan 08, 2004 6:38 pm
Post subject: Re: redirect german traffic with mod rewrite [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hello Michael,

thank your for your help. You wrote that it is possible via apache and
the browser language to redirect traffic.
This is exacly what I am searching for. I am launching a german site
while the english one exists now for quite a while. Now I would like to
redirect the german community members to the new german site, or even
better give them a popup with the info that a german site is available.

I tryed to understand what the apache docs said here:
<font color=purple>  > <a style='text-decoration: underline;' href="http://httpd.apache.org/docs-2.0/content-negotiation.html</font" target="_blank">http://httpd.apache.org/docs-2.0/content-negotiation.html</font</a>>

But I did not get it. I do have a .htaccess file. Can I just put one or
two lines in there and redirect germans to xx.de?

Thanx for your help,

Merlin

PS: I think google does it the same way?!



Michael Fuhr schrieb:
 > Merlin <news.letters.RemoveThis@web.de> writes:
 >
 >
  >>I am wondering how those big sites like google redirect specific
  >>internet traffic. Is it possible to create a rewrite rool containing the
  >>german, austrian and swiz ip adresses and shift this traffic a german site?
 >
 >
 > What's the purpose of this redirect? Is the user's country important,
 > or is it really the user's language that matters? If the latter, then
 > have a look at the Content Negotiation documentation:
 >
<font color=purple> > <a style='text-decoration: underline;' href="http://httpd.apache.org/docs-2.0/content-negotiation.html</font" target="_blank">http://httpd.apache.org/docs-2.0/content-negotiation.html</font</a>>
<font color=purple> > <a style='text-decoration: underline;' href="http://httpd.apache.org/docs/content-negotiation.html</font" target="_blank">http://httpd.apache.org/docs/content-negotiation.html</font</a>>
 >
 >
  >>The only thing I found is this:
  >>RewriteCond %{REMOTE_ADDR} =nnn.nnn.nnn.nnn
  >>
  >>But this goes only for one IP adress and not for a complete range.
  >>
  >>Does anybody know how to do that?
 >
 >
 > You could omit the "=" and use a regular expression. The URL
 > Rewriting Guide has examples:
 >
<font color=purple> > <a style='text-decoration: underline;' href="http://httpd.apache.org/docs-2.0/misc/rewriteguide.html</font" target="_blank">http://httpd.apache.org/docs-2.0/misc/rewriteguide.html</font</a>>
<font color=purple> > <a style='text-decoration: underline;' href="http://httpd.apache.org/docs/misc/rewriteguide.html</font" target="_blank">http://httpd.apache.org/docs/misc/rewriteguide.html</font</a>>
 >
 > You could also use a module like mod_geoip to map the IP address
 > to a country and then make decisions based on the country:
 >
<font color=purple> > <a style='text-decoration: underline;' href="http://www.maxmind.com/app/mod_geoip</font" target="_blank">http://www.maxmind.com/app/mod_geoip</font</a>>
 >
 > Note: there's no way to guarantee what country a user is in by
 > examining the user's IP address. The organization that owns the
 > IP address might have international operations, or the user's real
 > IP address might be hidden by a firewall or proxy.
 ><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: redirect german traffic with mod rewrite 
Back to top
Login to vote
mfuhr

External


Since: Nov 17, 2003
Posts: 44



(Msg. 4) Posted: Thu Jan 08, 2004 8:41 pm
Post subject: Re: redirect german traffic with mod rewrite [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Merlin <news.letters.DeleteThis@web.de> writes:

 > thank your for your help. You wrote that it is possible via apache and
 > the browser language to redirect traffic.
 > This is exacly what I am searching for. I am launching a german site
 > while the english one exists now for quite a while. Now I would like to
 > redirect the german community members to the new german site, or even
 > better give them a popup with the info that a german site is available.
 >
 > I tryed to understand what the apache docs said here:
<font color=green>  > > <a style='text-decoration: underline;' href="http://httpd.apache.org/docs-2.0/content-negotiation.html</font" target="_blank">http://httpd.apache.org/docs-2.0/content-negotiation.html</font</a>>
 >
 > But I did not get it. I do have a .htaccess file. Can I just put one or
 > two lines in there and redirect germans to xx.de?

Content negotiation allows you to create files for different languages
and have the web server automatically choose one based on the user's
language preferences. For example, if you have "Options +MultiViews"
set for a directory, then you could put the following files in that
directory:

index.html.en
index.html.de

If the user's preferred language is English, then Apache would serve
index.html.en; if the preferred language is German, then Apache
would serve index.html.de. If the preferred language is something
else, then the LanguagePriority and ForceLanguagePriority directives
determine what happens: you can have Apache use a default language,
or you can have it ask the user to choose from the available
languages.

Having Apache redirect the user to another web site based on their
language preference involves a little more work. A simple -- but
flawed -- way to do this with mod_rewrite would be:

RewriteEngine on
RewriteCond %{HTTP:Accept-Language} ^de
RewriteRule (.*) <a style='text-decoration: underline;' href="http://xx.de/$1" target="_blank">http://xx.de/$1</a> [R,L]

This method is flawed because it works only if the Accept-Language
header from the user's browser has "de" listed first. Having the
preferred language listed first is common but isn't required, and
the above method doesn't allow for German being acceptable but not
preferred (e.g., the user might prefer Italian but will accept
German if Italian isn't available). See RFC 2616 Section 14.4 for
more information about how the Accept-Language header works:

<a style='text-decoration: underline;' href="http://www.rfc-editor.org/rfc/rfc2616.txt" target="_blank">http://www.rfc-editor.org/rfc/rfc2616.txt</a>

A more reliable way to force a redirect would be to allow content
negotiation to select a file based on the user's language preferences
and have that file issue the redirect. You could use CGI or PHP
to do this, or you could put the following in the <head> section
of an HTML file:

<meta http-equiv=refresh content="0;URL=http://xx.de/">

Note that using http-equiv=refresh is considered bad style by some
people because it can break the browser's "back" button:

<a style='text-decoration: underline;' href="http://www.w3.org/QA/Tips/reback" target="_blank">http://www.w3.org/QA/Tips/reback</a>

Using CGI or PHP to send an HTTP redirect would probably be better.

--
Michael Fuhr
<a style='text-decoration: underline;' href="http://www.fuhr.org/~mfuhr/" target="_blank">http://www.fuhr.org/~mfuhr/</a><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: redirect german traffic with mod rewrite 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
URL rewrite help - redirect complete URI - I want to dynamicaly generate pages for my domain name for example, I want to internally redirect mydomain.com/company/new to mydomain.com/parse.php?value=/company/new mydomain.com/anything to mydomain.com/parse.php?value=/anything I want to redirect....

mod rewrite - find word and redirect - How would I write a statement that will search the entire URL for a word or pattern and if found, redirect it? In other words if I wanted to search for the word 'monkey' anywhere in the url, whether as a parameter (like index.php?monkey) or..

Help needed - Mod Rewrite/redirect for subdomains - Hi, I'm in need of some assistance (read: please bail me out 'cos I'm really stuck!) My webhosts (www.1and1.co.uk) allow subdomains to be created so that for instance domain.co.uk/directory1 can be accessed through subdomain1.domain.co.uk..

Newbie: Wikipedia - rewrite redirect ??? - Hey, i have installed wikimedia on my local computer, now the pages are always like wiki/index.php?title=Mainpage how can i maked it like wikipedia that it looks like wiki/Mainpage? thanks, liss

Using mod ReWrite to redirect request with certain paramet.. - Hello; I want to capture, and redirect, URLs that contain certain parameters (after the ?). I have been reading a number of articles (web pages) on mod Rewrite, but can't seem to get it working like I want. For example, I want to redirect all URLs..
   Web Hosting Problem Solving Community! (Home) -> Apache All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]