Allow access from specific referer only in .htaccess

I have a website with a wordpress installation and I’m using modrewrite to display clean urls. I want the visitors that are comming from facebook to access the site , while the others redirected to other , i made one , its working , but i am not sure how to redirect the denied visitors to the other site

 # 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


RewriteCond %{HTTP_REFERER} !(www.)?facebook.com
RewriteCond %{HTTP_REFERER} !(www.)?fb.com
RewriteCond %{HTTP_REFERER} !(www.)?l.facebook.com
RewriteCond %{HTTP_REFERER} !(www.)?goo.gl



RewriteRule .* - [F] 

Related posts

1 comment

  1. Your RewriteRule should have a full URL of the one that you want to redirect to.
    For example:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !(www.)?facebook.com
    RewriteCond %{HTTP_REFERER} !(www.)?fb.com
    RewriteRule ^ http://www.non-facebook-refer.com [R=301,L]
    </IfModule>
    

Comments are closed.