Forum Moderators: phranque

Message Too Old, No Replies

a referer deflector page

send users to where they need to go

         

winglian

5:20 pm on Feb 2, 2005 (gmt 0)

10+ Year Member



I was hoping to use mod_rewrite to send users to a specific page on the site. This will all be manually coded since I am simply checking my referers and deciding which page/content is appropriate.

Here's the snippet from my httpd.conf. I've commented it out since it doesn't work

# check for who the referer is and if they are coming to the main site from the referer page, send to another specific page
# still buggy, needs work
# RewriteMap deflector txt:/var/www/website/.htdeflector
# RewriteCond %{HTTP_REFERER}!=""
# RewriteCond %{REDIRECT_SCRIPT_URI}!="/"
# RewriteCond ${SCRIPT_URL} ^[^a-zA-Z.]$
# RewriteCond ${deflector:%{HTTP_REFERER}¦NOT-FOUND}!=NOT-FOUND
# RewriteRule ^.* ${deflector:%{HTTP_REFERER}}? [R=301,L]

and of course the .htdeflector file would be something like

[somereferingsite1.com...] /pageforsite1.html
[somereferingsite2.com...] /pageforsite2.html

however, when i use this, it usually ends up in an endless loopl since, even after the redirect, it still brings up the referer as the original refering page.

Thanks
Wing Lian

jdMorgan

11:02 pm on Feb 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just use another RewriteCond to prevent a rewrite if the URl is already "/pageforsite1.html".


RewriteMap deflector txt:/var/www/website/.htdeflector
RewriteCond %{HTTP_REFERER} .
[b]RewriteCond %{REQUEST_URI} [i][/i]!^/pageforsite1\.html$
RewriteCond %{REQUEST_URI} [i][/i]!^/pageforsite2\.html$[/b]
RewriteCond %{REDIRECT_SCRIPT_URI} !^/$
#RewriteCond ${SCRIPT_URL} ^[^a-zA-Z.]$
RewriteCond ${deflector:%{HTTP_REFERER}¦NOT-FOUND} !^NOT-FOUND$
RewriteRule ^.* ${deflector:%{HTTP_REFERER}}? [R=301,L]

I left that one line commented-out, because I don't know what you're intending to do with it.

Jim