Redirect request based on user agent

I need to redirect the user based on the Useragent.

Currently my wordpress site using ajax based theme. So the url format is

http://www.example.com/#!/my_first_post/

My current htaccess code is as follows.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

This is what I need help to do:

if (user agent == "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)" ){
 redirect the url without hashes
 ex:http://www.example.com/my_first_post/
}

I need to do this using htaccess. Please help me.

Answers


There's a mod_rewrite variable to detect user-agents:

RewriteCond %{HTTP_USER_AGENT} facebookexternalhit/1\.1 [NC]

but it's not going to help you. There is no way you can match a URL fragment in your htaccess file because the fragment is never sent to the server. URL fragments are completely on the client side, so you're best bet is to add some modifications to your theme to do the user agent check and have it not use fragments if it's from facebook.


Need Your Help

Is it possible to build a sitecore data package from command line, or outside of a web context? i.e. using nant

msbuild continuous-integration build-automation nant sitecore

The Sitecore package wizard can be used to build a package containing data and files for the local Sitecore instance.

what is the best cloud computing platform for biopython?

python cloud bioinformatics

i'm currently working (as a senior project) building and implementing a bioinformatics web application to manipulate large data &amp; some some complex work on them

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.