Mobile redirect of .NET site - how to setup in IIRF?

411 views Asked by At

I am working on a .NET based mobile site (m.website.com). I am using IIRF on the main site (non-mobile) for URL rewriting.

Now, it is required to redirect any mobile user to the mobile site if they land up on the main site (www.website.com). I am able to achieve this by checking the user agent in IIRF and redirecting.

The issue I'm facing is that:

The mobile site will have a link back to the main site. If a mobile user clicks on this link then he should not be redirected back to the mobile device.

I tried to follow the htaccess solution mentioned in this post - Mobile Redirect using htaccess but its not working properly with IIRF. RewriteCond for {QueryString} is not working properly. Also, I am not sure if I can set a cookie from IIRF itself, the way its mentioned in the link.

I have been struggling with this issue for quite a few hours, it would be great if someone could help.

Another approach I tried was checking the HTTP_REFERER to avoid redirection if the referring site is the mobile site but that did not work as well.

1

There are 1 answers

1
marapet On

IIRF does not offer the [co] modifier to set a cookie - but you should be able to do that easily from within .NET.

IIRF however supports checking for cookie values by using {HTTP_COOKIE} in your conditions.

{QUERY_STRING} is also supported (just make sure to include the underscore). Also, it's HTTP_REFERER, not HTTP_REFERRER (a misspelling we'll have to live with...).

You could therefore adapt the rewrite rules based on the user agent (where does that list come from??) from the question you linked. Redirect to the mobile site if:

  • the url asked for is not already the mobile site
  • the url does not contain the no-redirect querystring (?noredirect=1 or similar)
  • the no-redirect cookie is not present
  • the user agent matches the magic long list from the linked question