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
Printable View
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
Hi Lee,
Take a look at the code below:
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} ^Opera.*
RewriteRule ^.*$ redirectToWebsite [L]
This will redirect all the Mozilla and opera browsers to redirectToWebsite.Code:RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*
RewriteCond %{HTTP_USER_AGENT} ^Opera.*
RewriteRule ^.*$ redirectToWebsite [L]
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:
I hope this will help you!Code:RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^Opera.*
RewriteRule ^tour.*$ redirectToWebsite [L]
Best Wishes,
Arian