Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 2.x
 Helicon Tech : ISAPI_Rewrite 2.x
Subject Topic: Need help with ISAPI rule for iPad Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
frito833
Newbie
Newbie


Joined: 30 June 2010
Online Status: Offline
Posts: 1
Posted: 30 June 2010 at 10:21am | IP Logged Quote frito833

Here's my condition.  If the user is browsing a site using an iPad, I want to redirect them to an iPad version of their site.  They also have the option of returning to their regular site by clicking a "Desktop Version" link. Three things happen when they click the link. 

1) Pass a ForceDesktop=1 url paramenter
2) Create a ForceDesktop cookie to true
3) Redirect them out of the iPad subdirectory.

Here's the ISAPI code.

RewriteCond User-Agent:  .*(iPad).*
RewriteCond URL             ^(?!.*/iPad/)(?!.*ForceDesktop=1).*
RewriteCond Cookie:        .*(?!.forcedesktop).*
RewriteRule .*                /iPad/index.html?                [I,RP]

So basically, if ForceDesktop parameter isn't set or equal to 1, or forcedesktop cookie doesn't exists, take them to the iPad version.  My problem is if they click on any other links on the desktop version, they get booted to iPad version.   RewriteCond Cookie seems to not be working. Forcedesktop cookie is getting set in the header and should fail this test.  Any help is very much appreciated. 
Back to Top View frito833's Profile Search for other posts by frito833
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10489
Posted: 01 July 2010 at 3:33am | IP Logged Quote Anton

Please try to fic your code like this:

RewriteCond User-Agent: .*iPad.*
RewriteCond Cookie:      (?!.*forcedesktop.*).*
RewriteRule (?!.*(?:/iPad/|ForceDesktop=1).*).*   /iPad/index.html [I,RP]

One thing I'm concerned about is that you say "if ForceDesktop parameter isn't set or equal to 1, OR forcedesktop cookie doesn't exists".
This OR, as I understand, means that if at least one condition is true, redirect should occur, right?

__________________
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