Results 1 to 2 of 2

Thread: Browser Redirects Using Htaccess?

  1. #1
    You do realize by 'gay' I mean a man who has sex with other men?
    Join Date
    Oct 2003
    Location
    New Orleans, Louisiana.
    Posts
    21,635

    Browser Redirects Using Htaccess?

    Does anyone know how i would go about using .htaccess to redirect users of a specific browser from hitting my sites, for example, lets say a surfer is using Opera, how would i go about redirecting that surfer to a different website?

    Regards,

    Lee


  2. #2
    Red Axe Programmers
    Join Date
    May 2008
    Location
    Amsterdam
    Posts
    10

    Redirects browsers

    Hi Lee,

    Take a look at the code below:

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_USER_AGENT} ^Opera.*
    RewriteRule ^.*$ redirectToWebsite [L]
    This will redirect all requests from an opera browser to redirectToWebsite. If you want more specific browser to be redirected you can do something like this:

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*
    RewriteCond %{HTTP_USER_AGENT} ^Opera.*
    RewriteRule ^.*$ redirectToWebsite [L]
    This will redirect all the Mozilla and opera browsers to redirectToWebsite.

    The part ^Mozilla.* is a regular expression so it can match a lot of different browsers are once.

    The part ^.*$ after the RewriteRule is also a regular expression. If you want to redirect the opera browser when they hit the all the files that starting with tour in their filenames you can do this:

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_USER_AGENT} ^Opera.*
    RewriteRule ^tour.*$ redirectToWebsite [L]
    I hope this will help you!

    Best Wishes,
    Arian


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •