November 25, 201312 yr Hello. I am currently trying out a new few things whilst making my website but I have run into a problem I am hoping someone could assist me with. I have a website at www.abc.com which is the main domain but I want to be able to make it redirect to www.abc.com/xyz if they come from http://www.facebook.com. So in other words my website is www.abc.com which is the domain for public users but if they come from Facebook I want it to redirect to a folder on my website which is customised for Facebook if that makes sense. I have tried using HTACCESS but can't get it to work. This is what I have tried, I am still learning so code may be wrong: RewriteEngine On RewriteCond %{HTTP_HOST} ^www.abc.co.uk$ [NC] RewriteCond %{REQUEST_URI} ^/facebook$ RewriteRule ^/?a/(.*)$ https://www.facebook.com/$1 [R=301,L]
November 26, 201312 yr Author Please can someone help. Even if you can point me into the right direction of finding it out myself it would be much appreciated. Am I supposed to do it in HTACCESS?
November 26, 201312 yr Might be useful http://stackoverflow.com/questions/13106299/redirect-using-htaccess-based-on-referrer
November 26, 201312 yr Author Might be useful http://stackoverflow.com/questions/13106299/redirect-using-htaccess-based-on-referrer Thank you, I will take a look at this and see what I can do, will let you know if I do just in case anyone else wants to know in the future
November 26, 201312 yr Author I managed to get it to work using: RewriteEngine On RewriteCond %{HTTP_REFERER} !^https://www.facebook.com/ [NC] RewriteRule ^ http://www.buy-sell-today.co.uk/facebook/index.html [L,R] But it won't actually load up the webiste: take a look at the screenshot here: http://puu.sh/5tRPo.jpg Edited November 26, 201312 yr by oChapperZo
November 26, 201312 yr Try removing the http RewriteEngine On RewriteCond %{HTTP_REFERER} !www.facebook.com/groups/1387722168128069 [NC] RewriteRule ^/?facebook/$ www.buy-sell-today.co.uk/ [L,R] but I'm only guessing
November 26, 201312 yr Author Still don't seem to be working - I'm starting to fix if it's easier to create a directory and on Facebook add that URL instead but I would prefer just having http://www.buy-sell-today.co.uk and understand if the link comes from Facebook it loads up the Facebook side of my website.
November 27, 201312 yr You could place this javascript in your document <script> if (document.referrer.indexOf('http://www.facebook.com./') == 0 ) { location.href = 'www.abc.com/xyz'; } </script> It's a dirty fix but it should work for most users
November 27, 201312 yr Author I will try and use this code and see what happens, I will get back to you. Why would this technique be "dirty". I guess the correct way is to use HTACCESS?
November 28, 201312 yr I will try and use this code and see what happens, I will get back to you. Why would this technique be "dirty". I guess the correct way is to use HTACCESS? The reason I call it "dirty" is because it's done with javascript and the link could therefore mislead search engines trying to follow it (and other non-js-users). I'm sure it's possible to create an identical script with PHP (or whatever serverside language you are using) I just don't know the exact syntax. A serverside or HTACCESS redirection or would be a cleaner solution and ensure that all users gets redirected regardless if they have javascript enabled or not. Let me just add: I don't fear you will get a google "penalty" for using js redirects (Unless maybe if you redirect users to some totally unrelated url) Edited November 28, 201312 yr by Nillervision
November 29, 201312 yr A quick question; why do you want to get facebook users to go to www.abc.com/xyz? Is it different content or is it simply you want to count fb traffic?
December 1, 201312 yr ^^ Same question here. Using the HTACCESS seems preferable to javascript in case it is disabled. This is my best guess: RewriteEngine on RewriteCond %{HTTP_REFERER} ^http://(www\.)?facebook\.com RewriteRule ^$ /facebook/index.html [L] If it is for Analytics reasons it would probably be better to configure your analytics.
Create an account or sign in to comment