Redirect from old map to new one
Hi -
Simple issue that my lack of web programming is presenting -
We're replacing an older Silverlight viewer map with a new HTML5 one. Ready to go. I want to have a redirect for people who use the old url to go to the new map. I believe I have some html code that works, but what I am uncertain of is where to drop that code - guessing it has to be in the inetpub folder files somewhere, but any direction would be greatly appreciated.
Thanks
Allen
-
Hi Allen
have a look here for starters:
Essentially there are a range of options.
Here are 2:
whether you want to use Javascript:
<!DOCTYPE html>
<html>
<head>
<script>window.location.assign("http://your_new_site.com")
</script>
</head>
<body>All the silverlight stuff here
</body>
</html>or meta-tags
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Refresh" content="5;url=http://your_new_site.com">
</head><body>
All the silverlight stuff here
<p>If you see this message for more than 5 seconds, please click on the link above!</p>
</body></html>
or something else still. Note these are either edits of your viewer.html files or full replacements
Regards
Ralph Price
0 -
Thanks Ralph -
We're set to go the javascript route, even have the code written. The main question I have is where in the many Geocortex config files to drop the code. I'm guessing inetpub, and within there, a silverlight related config file since that's the 'old' map that we want to redirect away from.
0 -
Hi Allen
when a user starts the Silverlight viewer they are essentially going to an html page called viewer.html
Depending on how you have set your system up it is likely to be somewhere like C:\inetpub\wwwroot\GSLV where GSLV is the name that I gave the Silverlight install when doing the initial Silverlight install in the Post-Install configuration process.
I would suggest that the javascript snippet posted earlier could be the last piece of javascript in the header element.
Just tested now and that would appear to work fine. ie one location only required to send them to your new page
Regards
Ralph Price
0 -
Ah that makes perfect sense -
Will give that a try. Many thanks.
Allen
0 -
Quick revisit of this issue -
My main concern is that since all Silverlight maps launch with the viewer.xml file in inetpub, how does one code the redirect so that it is site specific?
For example, if we have 4 silverlight sites, and only 2 of them need to be redirected to new HTML5 versions, how can this be handled in the inetpub silverlight viewer.xml file since that is a general file and not specific to individual sites?
0 -
Allen,
I had the same need as you, and below is what I inserted into the Viewer.html file located in ...\inetpub\wwwroot\SilverlightViewer folder.
Inside the <head> tag right after this line of code <script type="text/javascript" src="ViewerCommandHandler.js"></script>
insert this code below:
<script type="text/javascript">
function getQueryStringArray(){
var assoc=[];
var items = window.location.search.substring(1).split('&');
for(var j = 0; j < items.length; j++) {
var a = items[j].split('='); assoc[a[0]] = a[1];
}
return assoc;
}
var qs = getQueryStringArray();
var url = '';
if (qs.Viewer !== 'undefined' && qs.Viewer) {
switch (qs.Viewer) {
// In the case statement, fill out the information with the Viewer name and type in the URL you want it to be redirected to
case 'Nothing':
url = 'your url you wish to redirect to';
break;
// DO NOT REMOVE THE DEFAULT BELOW
default:
url = 'blank'
}
if (url != 'blank') {
window.location.href = url; //reroute
}
else {
}
}
</script>For example - (http://geocortex.com/Silverlightviewer/) geocortex.com/SilverlightViewer/Viewer.html?Viewer=Nothing would redirect to the URL variable set in the Case Statement.
Continue to add case statements to that code for each viewer you wish to redirect. NOTE: This is assuming you have shortened your url in the Viewer.Settings.xml file.
Nelson Dobbs
0 -
This is great, thanks Nelson.
I have it working for one site, but am not getting the syntax right for adding in a second case statement. I have it set like so:
case 'Map1':
url = 'https://newurl_for_Map1';
case 'Map2':
url = 'https://newurl_for_Map2';break;
Have tried it with a 'break;' between the two case statements, but that's not quite right either.
Allen
0 -
So this below doesn't work?
case 'Map1':
url = 'https://newurl_for_Map1';
break;case 'Map2':
url = 'https://newurl_for_Map2';break;
0 -
Nope, doesn't appear to.
Map1 redirect works as hoped for, but the 2nd item, Map2, still goes to the old (silverlight) site when using the syntax/format you mention.
Also, it appears that if I actually type the (shortened) url for the 'old' version of either map1 or map2 into a browser address, the redirect is ignored. It seems like it only works if you go to your silverlight landing page and choose the site name from the drop down. I've been using private browsing to avoid and cached stuff, but may manually clear all caches and see what that does.
Thanks again
0 -
I'm not terribly familiar with setting up URLs, but the way I handle them is to set up custom URLs on my web server. For example, our main app is called CityView, so I set up a new folder and Default.htm so my users go to https://www.mysite.org/CityView. The Default.htm contains iframe code if it's a desktop app, and if I want to redirect to the Handheld.html, I use and if/else statement to redirect devices with screen widths under 800 pixels.
The advantage I've found with this is that all I have to do to update my app is change the source URL in my Default.htm. I've used this to migrate from one GE viewer version to a newer one as well as from the GVS to the GVH. For my users, the URL is always the same, and all the production moves takes is a copy and paste of the new full viewer URL. It's also easy to move back to an older version if I find a showstopping bug in the newest version.
And in the event that the URL would change, then I just update the old Default.htm to redirect to the new URL.
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
10 Kommentare