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


    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:


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}

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
Community showcase
Published Dec 18, 2018 in Confluence Cloud

Happy holidays from our team to yours!

Hi Community!  2018 was filled with changes for our team, both big and small, and we've taken a lot of time to both celebrate our wins and recognize areas of improvement. One thing that we're a...

473 views 3 18
Read article

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