logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: How to redirect specific useragent on specific URLs
Author
haryono



Joined: 20 May 2015
Posts: 1
Location: Indonesia,Tangerang

PostPosted: Wed 20 May '15 21:59    Post subject: How to redirect specific useragent on specific URLs Reply with quote

Hello everybody,

I have question: How to redirect specific useragent on specific URLs to specific URLs in .htaccess [Question]

E.G

I want to redirect 301 with conditional:

Code:
useragent: Firefox
from my url1: domain[dot]com/old-url1/
from my url2: domain[dot]com/old-url2/


to

Code:
to new url1: in my url1: domain[dot]com/new-url1/
to new url2: in my url1: domain[dot]com/new-url2/


FYI:

I create this in my .htaccess but not work

Code:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} googlebot [NC]
RewriteRule ^/?this-is-url/?$ domain[dot]com [L,R,NC]


Thanks
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Tue 26 May '15 23:12    Post subject: Reply with quote

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} abc.com$ [NC]
RewriteCond %{HTTP_USER_AGENT} Googlebot [OR]
RewriteCond %{HTTP_USER_AGENT} msnbot [OR]
RewriteCond %{HTTP_USER_AGENT} Slurp
RewriteRule ^(.*)$ http://bcd.com/$1 [L,R=301]


test request
Code:

GET /something HTTP/1.1
Host: abc.com
User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; http://www.google.com/bot.html)


Code:

HTTP/1.1 301 Moved Permanently
Date: Mon, 15 Oct 2012 22:10:55 GMT
Server: Apache
Location: http://bcd.com/something
Content-Length: 289
Content-Type: text/html; charset=iso-8859-1


You can get a list of user agents here: http://www.user-agents.org/
Back to top


Reply to topic   Topic: How to redirect specific useragent on specific URLs View previous topic :: View next topic
Post new topic   Forum Index -> Apache