Przejdź do głównej treści

(Expert) Setting up custom URL redirects in the help center using javascript - Baza Wiedzy / Developer & Reporting / Portal Customization - Deskpro Support

(Expert) Setting up custom URL redirects in the help center using javascript

Lista autorów

Summary

  • This article is for advanced users, and allows you to set up custom URL redirects on your helpdesk. This is not an official part of the product - we will be using a trick/hack with javascript to create these redirects.

  • This works by embedding code in the 404 page, so if an end user hits a URL which does not exist, they can be redirected to the correct place.

  • This works for both cloud and on-prem customers. Root server access is not required.

Disclaimer

As this is an expert customization, this falls outside of scope of standard support, and is something you will need to build and manage yourself.

If you run intoany problems, you should revert your error404.html template to default in the template editor, and save.

When may you need this?

  • If you have a very specific naming convention for your content, and are not able to use our default URLs.

  • You have migrated from a legacy system, and would like to retain old URL’s, for ease of use and SEO.

Instructions?

  1. Write up your redirect rules:

< script >

window.onload = function () {

switch(window.location.href) {

case 'http://192.168.100.78/en/some-broken-page-1':

window.location.href='http://192.168.100.78/en/new-page-1';

break;

case 'http://192.168.100.78/some-broken-page2':

window.location.href='http://192.168.100.78/en/new-page-2';

break;

default:

break;

}

}

< /script >

In this example, these two redirects will occur:

http://192.168.100.78/en/some-broken-page-1 >> http://192.168.100.78/en/new-page-1

http://192.168.100.78/some-broken-page2 >> http://192.168.100.78/en/new-page-2

This can continue indefinitely, you just need to copy and duplicate the 3 lines, case, window, break - as demonstrated in this animation:

  1. You must the paste this into Admin > Help Center > Design > Open Template Editor > Error > error404.html

  1. Press Save, Apply and ensure to Save Settings on your HelpCenter (and for any brands you may want to apply it for)

It should start to function right away.

Przydatne Nieprzydatne

0 na 2 osób uznała tę stronę za przydatną

Dodaj komentarz

Zaloguj lub zarejestruj się, by złożyć komentarz.

Potrzebujesz przypomnienia hasła?