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

d June 7, 2013

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

0 votes
twong_atlassian
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 11, 2013

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 :(

d June 12, 2013

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.

twong_atlassian
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 12, 2013

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


RewriteRule blah blah blah.

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



d June 16, 2013

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
TAGS
AUG Leaders

Atlassian Community Events