<html> <head> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script type="text/javascript"> function UrlExists(url, cb){ jQuery.ajax({ url: url, dataType: 'text', type: 'GET', cache: false, complete: function(xhr){ if(typeof cb === 'function') cb.apply(this, [xhr.status]); } }); } UrlExists('https://r3-core.pages.uni.lu/howto-cards-internal/index.html', function(status){ var s = window.location.pathname; var pathArray = s.split('/'); console.log(s); console.log(window.location.href); // cut the entire subdomain path if (pathArray[0].length > 0) { sub = s.substr(pathArray[0].length+1); } else { sub = ''; } if(status === 200){ // internal pages if (sub.length > 0) { sub = 'internal/'+sub; } window.location.href = 'https://r3-core.pages.uni.lu/howto-cards-internal/stable/'+sub; } else { // external pages if (sub.length > 0) { sub = 'external/'+sub; } window.location.href = 'https://r3.pages.uni.lu/howto-cards/stable/'+sub; } }); </script> </head> <body> <p> Please follow to <a href="https://r3.pages.uni.lu/howto-cards/stable">https://r3.pages.uni.lu/howto-cards/stable</a>! </p> </body> </html>