How can I maintain a URL using Apache mod_rewrite through the Confluence authentication process?

I'm trying to implement some very simple URL's in Confluence to take users to common information. So for example, have the URL http://conf5/phones take the user to a page in a given space that contains information about our company phone system. Using mod_rewrite, I mostly have things the way I want, here is the relevant part of the Apache config:

RewriteEngine On

    RewriteRule ^/phones$ /display/ds/Phones [PT]

    ProxyRequests Off

    ProxyPreserveHost On

    <Proxy *>

        Order deny,allow

        Allow from all

    </Proxy>

    ProxyPass / http://conf5:8090/

    ProxyPassReverse / http://conf5:8090/

    ProxyHTMLURLMap / /confluence/

With this configuration, if a user is authenticated and they enter the URL http://conf5/phones, they are taken to the correct page and the browser bar is unchanged. However, if the user is not authenticated, they are taken to the login page, and then following the login, although they are taken to the correct page, I lose the simple URL and it changes back to the *actual* URL http://conf5/display/ds/Phones.

This brings me to my question, how can I preserve the rewritten URL through the authentication process so the user always sees http://conf5/phones in their browser bar?

1 answer

The login filter user uses the param os_destination to redirect you to the place you originally came from. I suppose you could get the behavior you want by setting a mod_rewrite to 301 the reqeust back to your conf5/display/ds/Phones if you detect that the referrer was the login page and that the reqeust goes to display/ds/Phones.

It's kind of brute force :(

Thanks, I had since noticed the os_destination in the browser bar:

login.action?os_destination=%2Fdisplay%2Fds%2FPhones

I've been thinking that perhaps a combination of mod_rewrite and the Confluence UrlRewriteFilter might do what I need, or perhaps just using the UrlRewriteFilter by itself. However, I'm running into Apache giving me 'too many redirects' errors when using both together, and the UrlRewriteFilter is giving me an exception when I use it by itself with the rule type set to 'passthrough'.

Do you have an idea of how one would write a rewrite rule that detects the referrer as the login page? I would be curious to try that and see if it ends up in a too many redirects situation or not.

RewriteCond %{HTTP_REFERER} yourdomain.com/login.action


RewriteRule blah blah blah.

Untested, but I don't see why it wouldn't work.



I played around with the RewriteCond but haven't been able to get it to trigger a match. I added the following to my Apache config:

RewriteLog logs/rewrite_log
RewriteLogLevel 9

RewriteCond %{HTTP_REFERER} /login\.action [NC]
RewriteRule ^/phones$ /display/ds/Phones [PT,L]

Using Safari with the Web Inspector turned on, it shows the referer page and seems like it should match following the login, but it doesn't.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Friday in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

274 views 11 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you