Apache RewriteRule on IRIS
Hi,
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>
ServerName test.domain.com
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]
</Directory>
<Location />
CSP On
SetHandler csp-handler-sa
</Location>
<Location "/csp/bin/Systems/">
SetHandler csp-handler-sa
</Location>
<Location "/csp/bin/RunTime/">
SetHandler csp-handler-sa
</Location>
DirectoryIndex index.csp index.html index.htm
</VirtualHost>
</IfModule>
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?
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
http://appname.yourdomain.com.in/csp/YourNameSpace/index.cls to httpS://appname.yourdomain.com.in/csp/YourNameSpace/index.cls
<IfModule rewrite_module>
RewriteEngine On
RewriteCond "%{HTTP_HOST}" "!^ appname \.yourdomain\.com\.in" [NC]
RewriteCond "%{HTTP_HOST}" "!^$"
RewriteRule "^/?(.*)" "https:// appname .yourdomain.com.in/$1" [L,R,NE]
</IfModule>
RedirectMatch ^/$ /csp/YourNameSpace/index.cls
3. Save and Restart Apache
Hope this will help you to sort out your issue.
Thanks
Saurav Acharjee
Hi Saurav,
Thanks for your very detailed response. Coudl I just confirm that you applied this enhancement to your Cache80.conf file please?
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/mod_rewrite.so
Good luck
Thanks
Saurav Acharjee