Search code examples
httphttpswebspherehttp-redirect

How to redirect a URL http to https on WebSphere Application Server v9


I have deployed an application on WebSphere Application Server v9.0 and enabled SSL for this application (listening on port 443) by adding the below in httpd.conf file and it works just fine.

LoadModule ibm_ssl_module modules/mod_ibm_ssl.so
<IfModule mod_ibm_ssl.c>
Listen 0.0.0.0:443
<VirtualHost *:443>
Alias /jde "Z:\IBM\WebSphere\AppServer\profiles\AppSrv/installedApps/<cellName>/<appName>.ear\webclient.war"
SSLEnable
</VirtualHost>
<Directory "Z:\IBM\WebSphere\AppServer\profiles\AppSrv/installedApps/<cellName>/<appName>.ear\webclient.war\WEB_INF">
Require all denied
</Directory>
<Directory "Z:\IBM\WebSphere\AppServer\profiles\AppSrv/installedApps/<cellName>/<appName>.ear\webclient.war">
Require all granted
</Directory>
SSLDisable
KeyFile Z:\IBM\HTTPServer/<srvrname>.kdb

I can now successfully access the application using the URL https://srvrname/jde/E1Menu.maf

Is there a way the URL can be updated/redirected to https://srvrname/jde/E1Menu.maf when a user enters http://srvrname/jde/E1Menu.maf in the browser. Thanks !


Solution

  • Use the rewrite_module by adding the following to the httpd.conf:

    LoadModule rewrite_module modules/mod_rewrite.so
    
    RewriteEngine on
    RewriteCond %{SERVER_PORT} =80
    RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
    

    Full documentation can be found here: https://www.ibm.com/support/pages/node/72233