# Mod Rewrite (for redirecting something not working...)

**URL:** https://forum.kirupa.com/t/mod-rewrite-for-redirecting-something-not-working/137035
**Category:** Uncategorized
**Created:** [February 10, 2005, 7:58pm UTC](https://forum.kirupa.com/t/mod-rewrite-for-redirecting-something-not-working/137035 "2005-02-10T19:58:07Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![thediablo](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@thediablo](https://forum.kirupa.com/u/thediablo)
#### Post date: [February 10, 2005, 7:58pm UTC](https://forum.kirupa.com/t/mod-rewrite-for-redirecting-something-not-working/137035/1 "2005-02-10T19:58:07Z")

</div>

Ok so i searched the forum mod rewrite… htaccess redirect, htaccess block etc…

and i ended with this

RewriteEngine On  
RewriteCond %{HTTP\_REFERER} !^http://(www.)?[mydomain.com](http://mydomain.com)(/)?._$ [NC]  
RewriteCond %{HTTP\_REFERER} !^$  
RewriteRule /_ [http://www.ANOTHER.com](http://www.ANOTHER.com) [R]

What i want to do…  
Block and redirect all pages that i dont list at my mod rewrite, gonna keep adding like 10 domains that can see the page and all the other will get redirected to google for example.

What i think it does so far…  
RewriteEngine On

- self explanatory

RewriteCond %{HTTP\_REFERER} !^http://(www.)?[mydomain.com](http://mydomain.com)(/)?.\*$ [NC]

- If the domain is equal to [http://www.mydomain.com/\*](http://www.mydomain.com/*)(anything else) or without the www or without the / at the end… END and display the site.

RewriteCond %{HTTP\_REFERER} !^$

- If the domain is anything else… continue to next line…

RewriteRule /\* [http://www.ANOTHER.com](http://www.ANOTHER.com) [R]

- Redirect the domain to [www.ANOTHER.com](http://www.ANOTHER.com).

So am i correct or way wrong?

Thanks in advance.
