Portal Redirection

Redirecting in the portal is straightforward but syntax is important!

I was recently playing around with ways I could redirect the web page that would open. This started after playing around with the Category feature and not being satisfied in how it showed in menus and breadcrumb. For my story, I was looking to redirect traffic from the category 'header' web page to the web page of the first category in the list.

There are 2 methods I have recently explored for redirecting web traffic on my portal.

  1. The simplest method is to create a 'Redirect' record. Seems simple enough doesn't it? None of my early Redirect records were working though so I went and implemented a solution based method 2 (more after this).
    In the end, the reason for my early issues was that I was using the incorrect syntax for the incoming URL - I was using the full URL. Instead use the Partial URL. So instead of "https://xxxxcommunityportal.powerapps.com/tr" use 'tr' ! Would have been nice to have this in the Microsoft documentation but, hey, this is how one learns!
    For my story, I created a new Redirect record (Portal menu, Redirect). Set the Name, Website, and Status Code as desired. The Inbound URL was set to the Category 'header' web page. The Redirect URL was set to the Partial URL of the first category.
  2. The next method is to add script to the web page. Scripts can be added on any 'content' portal web page under the Advanced section a the bottom of the page.
    For my story, I added the script below So on the Content Web Page related to Weg Page defined with the Partial URL of 'tr', add custom javascript as per below.
    This worked fine; however, it meant a noticeable 'flip' on the screen. This is because the intial page (tr) needs to be loaded first before running the script -after loading it redirects to the target page (tr/tro). This small fraction of time is not significant but...unpleasant. 

$(document).ready(function() {
window.location.href = "/tr/tro/";
});

Certainly, option 1 is much preferred but I thought it might be useful to mention this alternative should the need arise.

Post a comment