Forum Moderators: phranque

Message Too Old, No Replies

Redirect unless self request

         

DKDiveDude

1:59 pm on May 15, 2004 (gmt 0)

10+ Year Member



For a site with subscription content, I have a general "join" page that offer several billing options.

For each billing option I offer, I have in a seperate folder, the actual "join" page.

I want all requests coming from outside my site, to the actual join pages, to goto the general join page.

What is the best way to do that?

gergoe

2:23 pm on May 15, 2004 (gmt 0)

10+ Year Member



with the request comming from outside of your site you mean to check the refering page, and if it is not a page on your site, then send the browser to an another page?

DKDiveDude

2:29 pm on May 15, 2004 (gmt 0)

10+ Year Member



Exactly

gergoe

7:52 pm on May 15, 2004 (gmt 0)

10+ Year Member



I could have tell you a lot about the flaw of the referer checking, but I recently came across a post of yours, where you explained that you don't care about browsers which do not send the referer header, so let's see what you can do:

RewriteCond %{REQUEST_URI} ^/([^/]+)/join\.html$ [NC]
RewriteCond %{HTTP_REFERER} ^$
RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.com/ [NC]
RewriteRule .* http://www.yourdomain.com/join.html [R,L]

This example assumes that the join pages in each folder are called join.html, and the folders are direct children of your root folder, where this rewriting should be placed. By removing the leading slashes and by adding the RewriteBase directive you can change this easily.

Be warned, if a browser does not send the referer header, the visitor will not be able to see any of the join pages other than the one in your root folder... Consider using some server-sided script with cookies, that's more reliable than the referer checking in this particular case.