i-Planet Administration Guide

URL Rewriting for HTML Files

Within HTML files, URLs can exist anywhere in JavaScriptTM. The URL rewriter must be able to open the page to which the URLs in the JavaScript statements refer. For the Java rewriter to be able to do this, you must modify the file /opt/SUNWsnrp/config/HTMLTranslator.config on the i-Planet gateway.

To Modify the File HTMLTranslator.config
  1. As root on the i-Planet gateway, add the following lines to the file /opt/SUNWsnrp/config/HTMLTranslator.config:


    JavaScriptRewrite=openNewWindow:y|parent.openNewWindow:y
    JavaScriptVariables=location.href|_fr.location|mf.location\
    
    |parent.location|self.location
    

    JavaScriptRewrite variable is set equal to the function openNewWindow or parent.openNewWindow and its flag set to y. Functions have the form func1:y, ,y, where func1 is the name of the function, the colon separates the name from the flags, and the flags are separated by commas. A flag is an instruction to translate a corresponding argument or not.

    The statement JavaScriptRewrite=func1:y, ,y|func2:,y,y means that if the variable JavaScriptRewrite finds func1 or func2 in an HTML page, it will rewrite it according to the flags set for the arguments to that function. If it finds func1, it will rewrite the first and third arguments because the flags for those arguments are set to y for yes, but not to the second argument. If it finds fun2, it will rewrite the second and third arguments because the flags for those arguments are set to y to yes, but not the first argument.

    The URL rewriter sets the JavaScriptVariables listed equal to the values for these variables that it finds in the JavaScript in an HTML page.

    For example, the variable JavaScriptVariable is set so that the line in the file reads JavaScriptVariables=location.href|_sr.href and an HTML page contains the following JavaScript:

    The URL rewriter looks through the JavaScript for the variables location.href and _sr.href. It finds a match for location.href, and it does not find a match for the variable loc (because the variable loc does not appear in the JavaScriptVariables statement). It also does not find a match for _sr.href.

    <script language=javascript> loc = "/cgi-bin/aaa.cgi"; location.href = "/cgi-bin/bbb.cgi";</script>

    The URL rewriter then sets the value of location.href equal to "/cgi-bin/bbb.cgi", and the HTML page becomes:

    <script language=javascript> loc = "/cgi-bin/aaa.cgi"; location.href = "https://i-Planet_gateway/http://destination_host/cgi-bin /bbb.cgi";</script>

    The variable loc remains unchanged since there are no instructions in the JavaScriptVariables statement for rewriting it.

  2. Stop and restart the reverse proxy on the i-Planet gateway for the change to take effect.

    See the procedure "To Stop and Restart the Reverse Proxy Server on the i-Planet Gateway" in this chapter.