View Full Version : .htaccess Redirect with condition
CriTiCeRz
October 26th, 2007, 06:34 PM
So what I'm trying to do is only allow people that come from a certain site to view a website. If they don't come from the site in the list, then they will be redirected somewhere else. So here is a way to do it that someone posted, but it's not working for me:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} !^http://www\.alainfontaine\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://www\.kirupa\.com/ [NC]
RewriteRule ^.*$ http://www.yahoo.com [r=301,L]
It's just an example. But it's not working right because it's redirecting everything to Yahoo. Even when I click my link from the kirupa forum.
You guys know of a way I can do this? If you know how to write the .htaccess code stuff this should be easy to do then.
Thanks in advance. :)
simplistik
October 26th, 2007, 09:48 PM
So what I'm trying to do is only allow people that come from a certain site to view a website. If they don't come from the site in the list, then they will be redirected somewhere else. So here is a way to do it that someone posted, but it's not working for me:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} !^http://www\.alainfontaine\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://www\.kirupa\.com/ [NC]
RewriteRule ^.*$ http://www.yahoo.com [r=301,L]
It's just an example. But it's not working right because it's redirecting everything to Yahoo. Even when I click my link from the kirupa forum.
You guys know of a way I can do this? If you know how to write the .htaccess code stuff this should be easy to do then.
Thanks in advance. :)
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://www\.alainfontaine\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://www\.kirupa\.com [NC]
RewriteRule ^(.*)$ http://www.yahoo.com/ [R=301,L]
CriTiCeRz
October 26th, 2007, 11:37 PM
Doesn't seem to work. Everything get's redirected to yahoo. Even links from here. :\
hl
October 27th, 2007, 09:51 AM
Alternatively, you can use PHP which is as simple as an array, use of the [d-php]in_array()[/d-php] function, followed by a [d-php]header()[/d-php].
simplistik
October 27th, 2007, 12:07 PM
Alternatively, you can use PHP which is as simple as an array, use of the [d-php]in_array()[/d-php] function, followed by a [d-php]header()[/d-php].
I figured it out and gave it to him on AIM, I also suggested just using PHP as well :lol: cause it's easier, but he insisted on .htaccess... booooo... I'll post the code on Monday
simplistik
October 31st, 2007, 04:53 PM
oh ooopsie heres the code for it
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www\.)?referrerssite\.com/ [NC]
RewriteRule ^(.*)$ http://www.google.com/ [R=301,L]
CriTiCeRz
October 31st, 2007, 06:11 PM
Thank you so much simplistik! :)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.