- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-18-2019 09:55 AM
Hello folks,
We have few portals which we are not using. So I made Default to false.
But still users are able to access those portals using urls.
I want to redirect users to our new portal(specific url) when they are accessing old portals.
Can some one please assist on this.
Thanks
Prasad K
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-18-2019 11:02 AM
You can replace Theme of old portals. Theme allows to include JS Includes, which will be loaded on attempt to display of every URL of old portals. Thus, you can create UI Script, which makes redirection to new portal, and load it as part of "Redirection Theme", which you assign to all old portals. The code of UI script can look as following:
(function () {
var loc = window.location;
//var oldUrl = loc.protocol + "//" + loc.host + loc.pathname + loc.search + loc.hash;
var newUrl = loc.protocol + "//" + loc.host + "/newPortal" + newSearch + loc.hash;
window.location.replace(newUrl);
})();
The method location.replace allows to redirect to new URL in very clean way. The current page will not be saved in session History, meaning the user won't be able to use the back button to navigate to it. As the result users will be able to use old links (for example links from old emails) and access to new URLs instead of old one. You can make the above code more complex and implement more complex algorithm of replacing of old URL to new one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-18-2019 11:02 AM
You can replace Theme of old portals. Theme allows to include JS Includes, which will be loaded on attempt to display of every URL of old portals. Thus, you can create UI Script, which makes redirection to new portal, and load it as part of "Redirection Theme", which you assign to all old portals. The code of UI script can look as following:
(function () {
var loc = window.location;
//var oldUrl = loc.protocol + "//" + loc.host + loc.pathname + loc.search + loc.hash;
var newUrl = loc.protocol + "//" + loc.host + "/newPortal" + newSearch + loc.hash;
window.location.replace(newUrl);
})();
The method location.replace allows to redirect to new URL in very clean way. The current page will not be saved in session History, meaning the user won't be able to use the back button to navigate to it. As the result users will be able to use old links (for example links from old emails) and access to new URLs instead of old one. You can make the above code more complex and implement more complex algorithm of replacing of old URL to new one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-27-2021 11:51 PM
For any other newbs like me, I had to change one thing in the above script for it to work exactly how I needed it. Here's my final code below:
(function () {
var loc = window.location;
//var oldUrl = loc.protocol + "//" + loc.host + loc.pathname + loc.search + loc.hash;
var newUrl = loc.protocol + "//" + loc.host + "/sp" + loc.search + loc.hash;
window.location.replace(newUrl);
})();
The key change was replacing newSearch with loc.search.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-02-2023 08:03 AM
Great explanation, thanks so much for the help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-25-2023 05:26 AM