Thursday, January 13, 2011

Replacing Tomcat .jsp pages with Apache httpd .php pages

It turned out that this task was much easier than I'd expected. Here are the steps I took:

  1. Edit the httpd.conf file (default path: C:\Apache2.2\conf\httpd.conf). Remove tomcat references to the services (JkMount). Add Redirect 301 lines to .php proxy
  2. Create php proxy which is referenced by Redirect 301. Arguments are passed by the redirect, which can be handled by this proxy. Here is the code I used for a single argument, but could easily be extended to other arguments. This also saves arguments that are not handled to a log file:
    $out = array();
    $log = '';

    foreach($_GET as $key => $value){
    if (strpos($key, 'max')){};
    switch ($key) {
    case bldgcode:
    $out['id'] = $value;
    $log .= 'key is ' . $key . ' and value is ' . $value . "\n";


    $fp = fopen('log', 'a');
    fwrite($fp, $log);

    $url = '' . http_build_query($out);

    header("Location: $url");