We have our JIRA instance running on a server, for example, JIRA_SERVER01. Users can get to that server by using URL http://JIRA_SERVER01/. We also created a CNAME to that server called JIRA so users can use a friendly name such as http://JIRA/ or fully qualified name, for example, http://JIRA.OurCompany.com/.
All of these URLs work fine, however, we want all of those URLs to automatically converged to the fully qualified name so regardless how users get to the JIRA application, the browser will always use the same URL and hence can take advantage of local cache and user’s cookies to restore the User’s last state.
Luckily, JIRA already uses a utility called UrlRewriteFilter (it is a Java Web Filter to be used on any J2EE compliant web application servers such as Tomcat, Resin or Orion) provided by http://www.tuckey.org/urlrewrite/.
Added the following rule elements to be the first node under the root node (urlrewrite) in the file urlrewrite.xml on the JIRA server:
<?xml version="1.0" encoding="utf-8" ?> <!-- Make sure users are always redirected to fully qualified name when a short name is entered for JIRA application --> <rule> <name>Canonical Hostname for jira.OurCompany.com</name> <note>The goal of this rule is to force the use of jira.OurCompany.com as the hostname to reach JIRA prod instance.</note> <condition operator="notequal" name="host">^jira\.OurCompany\.com</condition> <condition operator="notequal" name="host">^$</condition> <from>^/(.*)</from> <to last="true" type="permanent-redirect">http://jira.OurCompany.com/$1</to> </rule>
The file urlrewrite.xml should be in folder [JIRA_INSTALLATION_DIRECTORY]\atlassian-jira\WEB-INF
Note of Caution: This change is made in JIRA v4.2.1 running in a stand-along service mode. This is NOT officially supported by JIRA and use your discretion while making these kind of changes to JIRA installation files. As with any such unsupported changes, make them at your own risk and make sure you backup the files prior to your changes so you can revert to the original configuration if needed.
There may be other ways to achieve this same behavior, but this is what I did and it works fine for us.