Comment

Tim Blair, Investigative Reporter

1019
CuriousLurker4/27/2010 5:53:58 pm PDT

re: #742 Alouette

Typepad does not support 301 redirects. Even if they did, the 301 redirects everyone who comes to the page. How do you selectively redirect based on HTTP_REFERRER?

Sorry for disappearing on you—had to take care of a client problem.

You could put the following in an .htacess file in the root of your site, assuming that Typepad allows you to do that.

Part 1 - First (line 1), turn on RewriteEngine. Next (line 2) set the base path for the rules to your site’s public web root:

RewriteEngine On
RewriteBase /

If you get a message about an internal server error, use the following instead:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /

Part 2 - First (line 1), define the rewrite condition to look for, in this case it’s the HTTP_REFERER evildomain.com (the \ is needed to escape the dot in the domain name). Next (line 2), set the rewrite rule to Forbidden (403). Finally (line 3), instead of displaying the default 403 error page, set it to adl.org, which will automatically redirect anyone coming form evildomain.com to the ADL site:

RewriteCond %{HTTP_REFERER} evildomain.com [NC]
RewriteRule .* - [F]
ErrorDocument 403 adl.org

So your final .htaccess file would either look like this:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_REFERER} evildomain.com [NC]
RewriteRule .* - [F]
ErrorDocument 403 adl.org

Or this, if you have to use the Symlinks option:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_REFERER} evildomain.com [NC]
RewriteRule .* - [F]
ErrorDocument 403 adl.org

You can find a more detailed explanation of everything on this page.

Hope that made sense.