This forum has been moved here:
Helicon Tech Community Forum

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 2.x
 Helicon Tech : ISAPI_Rewrite 2.x
Subject Topic: Referer redirect Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
roulandf
Newbie
Newbie


Joined: 04 January 2010
Online Status: Offline
Posts: 2
Posted: 04 January 2010 at 8:11am | IP Logged Quote roulandf

Hello,

on my page I show images in a lightbox. My task is now to make these lightbox galleries accessable via direct links like http://www.domain1.com/show-gallery/title-of-gallery/12345 or if they come from an external page like Google (if visitors find a gallery in google's search result). I only have to rewrite the link above and redirect them to portals homepage (because with javascript I'm able to get the title (title-of-gallery) and the id (12345) from url of the gallery and then I'will open the lightbox).

I tried with the following condition (?!http://(.*)?(domain1|domain2|domain2|domain2)).* (the rule (RewriteRule ^/(show-gallery)/(\d+)?(\/)?([^\/]*)?(\/)?(\d+)? / [I,L]) itself works properly) but it sometimes redirect to / if I only want to open gallery lightbox on the page itself.

# redirect to portals homepage if referer is different than one of my domains.
RewriteCond Referer: (?!http://(.*)?(domain1|domain2)).*
RewriteRule ^/(show-gallery)/(\d+)?(\/)?([^\/]*)?(\/)?(\d+)? / [I,L]

Rewriting should work as follows:
a) Direct access via http://www.domain1.com/show-gallery/title-of-gallery/12345 should redirect to http://www.domain1.com/
b) From Google's search result user should be redirected to http://www.domain1.com
c) If user clicks on a gallery if he is on my page (http://www.domain1.com or http://www.domain2.com) the lightbox should open without any redirect.

Best regards,
Roland
Back to Top View roulandf's Profile Search for other posts by roulandf
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10520
Posted: 04 January 2010 at 9:12am | IP Logged Quote Anton

Please try to fix the rules like this:

RewriteCond Referer: (?!.*(?:domain1|domain2).*).*
RewriteRule /show-gallery/[^/]+/\d+ http\://www.domain1.com/ [I,RP]



__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
roulandf
Newbie
Newbie


Joined: 04 January 2010
Online Status: Offline
Posts: 2
Posted: 04 January 2010 at 10:43am | IP Logged Quote roulandf

Hi Anton,

I tried your version of these rules, but it does not work if I click the link (http://www.domain1.com/show-gallery/title-of-gallery/12345) from Google's search result.
When page is loaded, document.referrer looks like this: "http://www.google.at/url?sa=t&source=web&ct=res&cd=4&ved=0CBIQFjAD&url=http%3A%2F%2Fwww.domain1.com%2Fshow-gallery%2Ftitle-of-galery%2F12345&rct=j" and it seems that it does not match with (?!.*(?:domain1|domain2).*).*

Do you have any idea?


Kind regards,
Roland
Back to Top View roulandf's Profile Search for other posts by roulandf
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10520
Posted: 05 January 2010 at 3:52am | IP Logged Quote Anton

Firstly, please confirm it's ISAPI_Rewrite 2 you are using.

And please try to fix your config like this:

RewriteCond Host: .*(?:domain1|domain2).*
RewriteRule /show-gallery/[^/]+/\d+ http\://www.domain1.com/ [I,RP]

RewriteCond Referer: (?!.*(?:domain1|domain2).*).*
RewriteRule /url\?.*www\.(?:domain1|domain2)\.com/show-gallery/[^/]+/\d+.* http\://www.domain1.com/ [I,RP]



__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum