homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

how to control redirects from other domains

 5:15 am on Jun 27, 2011 (gmt 0)

I control the website at URL#1. I do not control URL#X nor URL#Y. Both URL#X and URL#Y contain backlinks to URL#1. I want to redirect traffic that arrives from URL#X to URL#2. However, I do not want to redirect traffic that arrives from URL#Y to URL#2. Is this possible?

In other words, simply adding the following to .htaccess will redirect all traffic from URL#X and URL#Y to URL#2. This is not what I want.
Redirect 301 URL#1 URL#2
Thank you for your help.



 5:28 am on Jun 27, 2011 (gmt 0)

Your magic words [httpd.apache.org] are


Don't look at me. It's their spelling.


 5:55 am on Jun 27, 2011 (gmt 0)

Thanks Lucy! I did look at [httpd.apache.org...] but I still don't know how to construct the directive. (I'm self-taught, but my teacher is a newbie :o Based on my example, can you help?


 8:01 am on Jun 27, 2011 (gmt 0)

RewriteCond %{HTTP_REFERER} ickysite/whose/visitors/youdon'twant
RewriteRule \.html?$ http://www.example.com [R=301,L]

The RewriteCond is a Regular Expression so you only need to give enough information to make it unique. (I've got one that says in full \.(ua|su|mobi)/ for example. 100% of my referers from these extensions are forged.)

The RewriteRule only gives the end of the address, because you're kicking out people who request any page. Or, ahem, sending them to a place where you're certain they would be a lot happier. This includes people who just type in "www.example.com", because server magic has already changed that into a full address.

All this is assuming that URL#2 is waiting with open arms to receive your unwanted guests. Ahem. Oh, and I assumed that when you said URL you meant "domain". Otherwise you have to make the RewriteCond a little more detailed.


 8:48 am on Jun 27, 2011 (gmt 0)

When redirecting to a domain, a trailing slash is required in order to specify the root page.

However, I would not redirect.

I use
RewriteRule <pattern> - [F] where <pattern> specifies which URL requests to block.

 8:55 pm on Jun 27, 2011 (gmt 0)

Hmm, not sure about what to do G1 and Lucy. When you wrote "ickysite/whose/visitors/youdon'twant" I got the idea that your regex will not do what I want: I do want visitors from URL#X and URL#Y at URL#1. I just don't want peeps from URL#Y to be redirected to URL#2 (as stated in the first para.) Not redirecting is a big difference from "kicking out people".

Please, please give the actual RewriteRule/RewriteCond example using the "URL#X" etc. examples, so that we stay on the same page. TIA!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved