Forum Moderators: phranque

Message Too Old, No Replies

htaccess redirection on language or browser

         

dewpoint

7:51 pm on Jul 5, 2003 (gmt 0)

10+ Year Member



As this is my first post on this board...hello!

I have an entire domain with hundreds of html pages. I wish to redirect any and all Spanish visitors to a single ad page on a different domain.

I don't want to have to add any code to each html page, but instead would prefer to globally redirect anyone who has their language preference set to Spanish.

Can anyone help me out with the htaccess entries. I have read over a number of reference sources..but the whole thing still confuses me somewhat.

For a different domain, and a separate project, I again wish to redirect any and all visitors, but this time, only if the surfer is using an AOL browser.

Thanks for any help you can throw my way!

dewpoint

10:17 pm on Jul 5, 2003 (gmt 0)

10+ Year Member



O.K...this is what I came up with for the AOL script. (But sadly, it doesn't seem to work). Any suggestions as to what I might be doing wrong.

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^AOL
RewriteRule ^.*$ [new...] site where I want all aol traffic to be redirected to [L,R]

claus

10:34 pm on Jul 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



dewpoint, welcome to WebmasterWorld :)

I was looking through my own log files to find an example of an AOL browser, but i didn't find a single one (the site is not from the US, not even in english). As i recall, the browser name ("User Agent string") does not start with AOL, rather it has AOL somewhere in it.

When you write this:

RewriteCond %{HTTP_USER_AGENT} ^AOL

-you state that the string should start with AOL. Remove the ^ character and it will be true no matter where in the string the AOL is located.

Regarding language: I'd like to know too. I know it can be done, as i recently had a project where it was done, but i did not code it.

/claus

claus

11:00 pm on Jul 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Language: Here's a link to a description of how it can be done [bowiesnyder.com]

I just found it, but it seems okay.

/claus

dewpoint

1:29 am on Jul 6, 2003 (gmt 0)

10+ Year Member



Hi Claus, adn thanks for your advice.

Here's what I tried (I used www.msn.com as my test redirect site).

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} AOL
RewriteRule ^.*$ [msn.com...] [L,R]

Here's the response I received, testing it with Netscape and IE:

Forbidden
You don't have permission to access / on this server.

Apache/1.3.27 Server at www.mydomain.com Port 80

I tried setting permissions on my htaccess file to 744, but same thing. I didn't add any other files...I've heard mention of a mod file. Am I missing something, like a mod file?

Thanks!

jdMorgan

2:06 am on Jul 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



dewpoint,

Do you have access to your raw server error log file? If so, check and see why this failed.

You also might want to try adding the following line ahead of RewriteEngine on:


Options +FollowSymLinks

Sometimes, this is required to enable mod_rewrite.

There is nothing intrinsically wrong with your code - it should have worked. If the above does not help, then there's something weird going on with your server.

Jim

dewpoint

5:42 pm on Jul 6, 2003 (gmt 0)

10+ Year Member



Thanks for the advice...this worked!~

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} AOL
RewriteRule ^.*$ [msn.com...] [L,R]

I tried the followng to redirect all Spanish traffic,but this did not work:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_ACCEPT_LANGUAGE} es
RewriteRule ^.*$ [msn.com...] [L,R]

Any suggestions?

Thanks again for all the help.

claus

6:03 pm on Jul 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It could be that the browser language and the browser accepted language are not the same. Sounds odd, but i really don't know how to explain it. Try this:

Are lines one and three the same on this test page [bowiesnyder.com]?

(for one of the spanish browsers that is.)

/claus

jdMorgan

7:38 pm on Jul 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



dewpoint,

You can also check your browser's request headers [searchengineworld.com] to make sure it is sending the "accept" headers you expect.

Jim