How can i redirect to another URL if ESC is no longer the prefix

Abigail
Tera Expert

I changed the prefix from Employee Center (esc) to another one, but the thing here is that I need to redirect anyone that is using this prefix to the new one, I want to know a way to trigger this.
Is there a way I can do this?

Thanks.

1 ACCEPTED SOLUTION

sushantmalsure
Mega Sage
Mega Sage

Hi Abigail

You can create UI script for such redirections (System UI > UI script) and put following redirection script

addLoadEvent(redirect);
function redirect() {
if(document.URL.indexOf('/esc') != -1){
 window.location = '/NEW_ESC'; //here replace new_esc with your new portal prefix
}
}

sushantmalsure_0-1712215790331.png

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

View solution in original post

8 REPLIES 8

share your script screenshot and test case you are trying with to help you better.

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

Onkar Pandav
Tera Guru

Hello @Onkar Pandav 

I already used that link, the problem is that I don't know how to redirect when the ESC prefix is no longer used on the portal prefix.


So I want to know if there is a way to redirect without a portal or page, only if I type the URL with the esc, will this redirect me to the new one. I was wondering if there was a way to trigger this, only with the URL

Try below code:

var currentURL = window.location.href;
var newURL = currentURL.replace("x", "y");
window.location.href = newURL;