Redirect strategies for coping with IE7

viktoras d. viktoras at ekoinf.net
Sat Jan 31 09:26:31 EST 2009


Sorry, fixed some errors and reposting again.

Try using server side includes (ssi/shtml). For example this is a simple
templating system where the same ssi template inserts different contents 
based on menu url clicked by a user. In general URL should look like 
this http://my.site.net/ssi_page.shtml?target

<!--#if expr="$QUERY_STRING=''" -->if query string is empty, including
contents from file called "intro":
<!--#include file="intro" -->
<!--#else -->
else include file whose name is specified by query string (target):
<!--#include file="$QUERY_STRING" -->
<!--#endif -->

your target might be password or username as well and for each case you
can specify include file manually, not necessary using parameter
submitted in $QUERY_STRING. Mix the ssi directives with html  of webpage
and this way you can include anything- ordinary text, contents of other
web page, graphics, different css stylesheets, javascripts, etc:

<img src = '<!--#if expr="$QUERY_STRING=/intro/ "   --> boo1.gif
<!--#elif expr="$QUERY_STRING=/portfolio/ "   -->portfelis.gif
<!--#elif expr="$QUERY_STRING=/partners/ "   -->partneriai.gif
<!--#elif expr="$QUERY_STRING=/research/ "   -->mokslas.gif
<!--#elif expr="$QUERY_STRING=/personali/ "   -->profilis.gif
<!--#elif expr="$QUERY_STRING=/contact/ "   -->kontaktai.gif
<!--#else -->paslaugos.gif<!--#endif -->'>

Now adding os and browser detection to the first example with inclusion
of different contents:
<!--#if expr="$QUERY_STRING=''" -->
if query string is empty, including contents from file called "intro":
<!--#include file="intro" -->
<!--#else -->
     <!--#if expr="$HTTP_USER_AGENT = /Windows/ && $HTTP_USER_AGENT =
/MSIE/" -->
    Windows and MS I.E zone
    <!--#include file="secret_folder/windz_msie.html" -->
    <!--#elif expr="$HTTP_USER_AGENT = /Linux/ && $HTTP_USER_AGENT =
/Gecko/" -->
    Linux Netscape/Mozilla zone
    <!--#include file="other_secret_folder/linx_moz.html" -->
    <!--#else -->
   Other OS/browser combination zone:
   <!--#include file="another_secret_folder/otheroz_boo.html" -->
    <!--#endif -->
<!--#endif -->

It is also possible to hide the technology in use by defining different
extension into .htaccess file of the directory with ssi pages:
AddType text/html .run
AddHandler server-parsed .run
DirectoryIndex index.run

Now instead of .shtml you can use .run extension and no one knows what
technology hides behind your pages :-).

Also (alternative), you can detect os/browser and secret url strings
using .htaccess only, but this is more complicated comparing to
ssi. For example the following will redirect to different pages based on
browser in use:
Options +FollowSymLinks
RewriteEngine  on
RewriteCond %{HTTP_USER_AGENT} ^Mozilla.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^Opera.*
RewriteRule ^$ /index_mozmsie.html [L]

RewriteCond %{HTTP_USER_AGENT} ^Lynx.*
RewriteRule ^$ /high_accessibility.shtml [L]

RewriteRule ^$ /high_accessibility.shtml [L]

In this example mozilla/opera/msie requests are redirected to
index_mozmsie.html and lynx users - to high_accessibility.shtml. If user
is not clear (e.g. mobile phones) it redirects to
high_accessibility.shtml page again.

And if you specify in the .htaccess:
RewriteCond %{HTTP_HOST} ^www.othersite.org [NC]
RewriteRule ^(.*)$ http://mysite.org/alternative_index.shtml [L]

now all requests to http://www.othersite.org on your server will be
redirected to http://mysite.org/alternative_index.shtml

Best wishes!
Viktoras




More information about the use-livecode mailing list