4

I created an excel hyperlink using something like the following: =HYPERLINK("https://abc.com/"&A1)

When I click on it, it opens up a new tab in Chrome asking me to login (the page has sensitive information and requires user authentication), even though I'm already logged in previously.

However, if I were to copy from the cell and paste it directly in the url bar in Chrome it automatically brings me to the page without logging in again.

Is there a way to sidestep this issue?

Glenn Low
  • 143
  • 1
  • 4
  • 11

1 Answers1

0

See Bharath's answer to a similar question here: Excel Hyperlinks redirecting to login

  1. Create a redirect.html page in your public folder (public folder because you are using ROR)
  2. Copy this to your redirect.html
 <html>
 <body>
 Please wait, loading your page... 
 <script type="text/javascript">
     function getQuerystring(key) {
         key = key.replace(/[\[]/,"\\\[").replace(/    [\]]/,"\\\]");
         var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
         var query = regex.exec(window.location.href);
         return query[1];
     }
     window.location = "http://" + window.location.host + "/" + getQuerystring('page');
 </script>
 </body>
 </html>

The links you are constructing in excel should be modified

For e.g Old link - http://test.com/post/comments/1 New link should be - http://test.com/redirect.html?page=post/comments/1

You need to pass the part of URL (after base url) as a param How this works.

When user clicks a link in excel it points to redirect.html and the javascript constructs the actual URL and redirects again to proper page, user will be navigated to actual page if already logged in else redirected to Login/Home page.

Community
  • 1
  • 1
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – reVerse Oct 25 '14 at 06:09
  • Thanks, I have just added. – Manigandan Dorairaj Oct 25 '14 at 06:49
  • I had the same problem, so I implemented something similar on my server. I'm including a google sheet with an example and the source code in php / javascript. Here's the link https://docs.google.com/spreadsheets/d/1n57gPAShPc58X-zROzAypX-fGA8_YJb3TaAKCVPFxJU/edit?usp=sharing – Mark N Hopgood Jan 26 '18 at 18:20
  • For an updated redirect.html, with Web APIs instead of regexes, see https://stackoverflow.com/a/70969243/685715 – Matt Wallis Feb 03 '22 at 10:06