· Nov 9, 2020

Apache RewriteRule on IRIS


I'm attempting to set up an Apache Rewrite Rule so that a url picks up a different csp page.

For example I want Apache http://hostname/csp/test/foo.csp to redirect to http://hostname/csp/test/bar.csp

Here is my example of Cache80.conf

<IfModule mod_ssl.c>
<VirtualHost _default_:80>
    DocumentRoot "/intersystems/irissys/csp"
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    LogLevel info
    <Directory /intersystems/irissys/csp/test>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
        RewriteEngine On
        RewriteRule "^/foo\.csp" "/bar.csp" [PT]
    <Location />
        CSP On
        SetHandler csp-handler-sa
    <Location "/csp/bin/Systems/">
        SetHandler csp-handler-sa
    <Location "/csp/bin/RunTime/">
        SetHandler csp-handler-sa
    DirectoryIndex  index.csp index.html index.htm

Unfortunately when I load http://hostname/csp/test/foo.csp in a browser, foo.csp loads instead of the desired bar.csp.

I've tried all sorts of variations of the rule to include directories but nothing I've tried seems to work.

Does anyone have idea what I may be doing wrong please?

Discussion (3)1
Log in or sign up to continue

Hi Steve,

There are several ways to achieve the redirection as per Apache docs.

I've used the following steps with the full version of Apache24  to redirect   to httpS://  

  1. Enable the "rewrite_module" 
  2.  Add the following...

<IfModule rewrite_module>
     RewriteEngine On

    RewriteCond "%{HTTP_HOST}"   "!^ appname \.yourdomain\.com\.in" [NC]
    RewriteCond "%{HTTP_HOST}"   "!^$"
    RewriteRule "^/?(.*)"        "https:// appname$1" [L,R,NE]

RedirectMatch ^/$ /csp/YourNameSpace/index.cls

   3.  Save and Restart Apache

Hope this will help you to sort out your issue. 


Saurav Acharjee

Hi Steve

I do not use the Apache that comes with the IRIS/Cache. I use the full version (Apache24) with my application. ( I found the full version of the Apache makes the web app more efficient )

I applied this enhancement to the httpd.conf file of the Apache24.  

I don't see any reason why this enhancement will not work with the Cache80.conf file (provided you enable the rewrite_module).  

In the full version, I had to enable the following

LoadModule rewrite_module modules/

Good luck


Saurav Acharjee