# .htaccess Redirect with condition

**URL:** <https://forum.kirupa.com/t/htaccess-redirect-with-condition/242525>\
**Category:** programming\
**Created:** [October 26, 2007, 10:34pm UTC](https://forum.kirupa.com/t/htaccess-redirect-with-condition/242525 "2007-10-26T22:34:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CriTiCeRz](https://avatars.discourse-cdn.com/v4/letter/c/ce73a5/32.png) [@CriTiCeRz](https://forum.kirupa.com/u/CriTiCeRz)\
**Post date:** [October 26, 2007, 10:34pm UTC](https://forum.kirupa.com/t/htaccess-redirect-with-condition/242525/1 "2007-10-26T22:34:19Z")

</div>

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:

```auto

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. 🙂
