locked
UAG HTTP trunk redirect 302 to 301 RRS feed

  • Question

  • Hi all,

    Our customer is running a website behind UAG and UAG does a http to https redirect with a redirect trunk configured. Problem is that UAG by default does a 302 redirect and our customer wants the redirect type changed to 301. Is there any way to configure this in UAG GUI or configuration files?

    BR,

    Matti T.

    Saturday, December 18, 2010 9:34 AM

Answers

  • Hi Matti,

    I see. Thanks for satisfying my curiosity J I was not aware of UAG customers being too concerned with search engines discoverability and popularity ratings for their UAG portals, since usually these sites are not meant to be used by “the public”,and therefore they are not usually searched for.

    Well, I’ll tell you how is a UAG redirect trunk performing the redirection, and you can decide whether or not is it worth to customize it in order to change the status from 302 to 301.

    If you open the Advanced Trunk Configuration window of a redirect trunk, and go to the Authentication tab, you can see that the User Logon Page is set to be: Redirect.asp?port=443

    If you take a look at this ASP script, found in the …\von\InternalSite folder, you can see the logic implemented in it in order to decide what is the URL to which the browser should be redirected (as you probably know, this URL is actually the Location header in the HTTP response sent back to the browser), and then, towards the end of the script, once the URL is computed, the ASP scripts invokes a response.redirect command. This causes the HTTP 302 response to be sent to the browser.

    If your customer wishes to change that, I guess he would have to do this (note that I have not tried this myself):

    1.     Create a custom ASP script, in the …\von\InternalSite\CustomUpdate folder. This script could, for example, be heavily based on the default Redirect.asp script, but instead of ending with a response.redirect command, it should probably utilize some Response.Status (to set the status to 301), Response.AddHeader (to set the Location header) and Response.Write commands.

    2.     Back on the Authentication tab of the Advanced Trunk Configuration of the redirect trunk, he would have to specify his custom version of the redirect script. So, in the User Logon Page, he should insert something like this: CustomUpdate/MyRedir.asp?port=443

    3.     Activate and test.

    HTH,


    -Ran
    • Marked as answer by Erez Benari Wednesday, December 22, 2010 10:41 PM
    Saturday, December 18, 2010 12:47 PM

All replies

  • Hi all,

    Our customer is running a website behind UAG and UAG does a http to https redirect with a redirect trunk configured. Problem is that UAG by default does a 302 redirect and our customer wants the redirect type changed to 301. Is there any way to configure this in UAG GUI or configuration files?

    BR,

    Matti T.

     

    Hi Matti,

    Sorry to answer your Q with another Q, but could you please explain why is a standard HTTP 302 redirect considered a problem, and why does your customer consider an HTTP 301 "Moved Permanently" a better solution? Are your customer's browsing clients some kind of clients that would "remember" this "permanent redirection" and would automatically request the https:// URL from here on?

    Thanks,


    -Ran
    Saturday, December 18, 2010 11:39 AM
  • Hi Ran,

    customer asked for this because they feel HTTP 302 redirects reduce their site's search engine visibility. They said "if links are created on other websites to the http:// url of the site, this reduces visibility in different www search engines if the http url uses 302 redirect and not 301". I hope this clarifies the scenario.

    Found this site that tells the story: http://webdesign.about.com/od/http/qt/tip301v302redir.htm

    - Matti

    Saturday, December 18, 2010 12:04 PM
  • Hi Matti,

    I see. Thanks for satisfying my curiosity J I was not aware of UAG customers being too concerned with search engines discoverability and popularity ratings for their UAG portals, since usually these sites are not meant to be used by “the public”,and therefore they are not usually searched for.

    Well, I’ll tell you how is a UAG redirect trunk performing the redirection, and you can decide whether or not is it worth to customize it in order to change the status from 302 to 301.

    If you open the Advanced Trunk Configuration window of a redirect trunk, and go to the Authentication tab, you can see that the User Logon Page is set to be: Redirect.asp?port=443

    If you take a look at this ASP script, found in the …\von\InternalSite folder, you can see the logic implemented in it in order to decide what is the URL to which the browser should be redirected (as you probably know, this URL is actually the Location header in the HTTP response sent back to the browser), and then, towards the end of the script, once the URL is computed, the ASP scripts invokes a response.redirect command. This causes the HTTP 302 response to be sent to the browser.

    If your customer wishes to change that, I guess he would have to do this (note that I have not tried this myself):

    1.     Create a custom ASP script, in the …\von\InternalSite\CustomUpdate folder. This script could, for example, be heavily based on the default Redirect.asp script, but instead of ending with a response.redirect command, it should probably utilize some Response.Status (to set the status to 301), Response.AddHeader (to set the Location header) and Response.Write commands.

    2.     Back on the Authentication tab of the Advanced Trunk Configuration of the redirect trunk, he would have to specify his custom version of the redirect script. So, in the User Logon Page, he should insert something like this: CustomUpdate/MyRedir.asp?port=443

    3.     Activate and test.

    HTH,


    -Ran
    • Marked as answer by Erez Benari Wednesday, December 22, 2010 10:41 PM
    Saturday, December 18, 2010 12:47 PM
  • Hi Ran,

    thank you for your detailed reply. We will try to customize the ASP script with the customer as soon as possible and activate the changes. I will post the results in this thread later on.

    - Matti

    Saturday, December 18, 2010 1:02 PM
  • Hi,

    We just finished testing this. We used the original script Redirect.asp, and modified it accordingly. Last lines in the original script:

     response.redirect orig_url 
    
    %>

    Were changed to:

    Response.Status="301 Moved Permanently"
    Response.AddHeader "Location", orig_url
    response.redirect orig_url 
    %>

    The the script was named Redirect_302_to_301.asp and moved to the ..\von\InternalSite\CustomUpdate\ folder. HTTP redirect trunk settings were then changed to "CustomUpdate\Redirect_302_to_301.asp?port=443" on the Authentication - User logon page setting. Config was activated and tested. It didn't work as expected, the result was a UAG message displaying this:

    " Application and Network Access Portal
    You cannot access this site due to an internal error.
    Try to access this site again in a few minutes.
    If the problem persists contact the site administrator."

    So the redirect did not work. We restored the original Redirect.asp?port=443 setting to the trunk settings, everything's back to normal.

    Is the modified script we used faulty in some way?


    Br, Matti
    • Edited by MTU10 Friday, January 7, 2011 12:10 PM code displayed wrong
    Friday, January 7, 2011 12:07 PM
  • Hi,

    We just finished testing this. We used the original script Redirect.asp, and modified it accordingly. Last lines in the original script:

     response.redirect orig_url 
    
    %>
    

    Were changed to:

    Response.Status="301 Moved Permanently"
    
    Response.AddHeader "Location", orig_url
    
    response.redirect orig_url 
    
    %>
    
    

    The the script was named Redirect_302_to_301.asp and moved to the ..\von\InternalSite\CustomUpdate\ folder. HTTP redirect trunk settings were then changed to "CustomUpdate\Redirect_302_to_301.asp?port=443" on the Authentication - User logon page setting. Config was activated and tested. It didn't work as expected, the result was a UAG message displaying this:

    " Application and Network Access Portal
    You cannot access this site due to an internal error.
    Try to access this site again in a few minutes.
    If the problem persists contact the site administrator."

    So the redirect did not work. We restored the original Redirect.asp?port=443 setting to the trunk settings, everything's back to normal.

    Is the modified script we used faulty in some way?


    Br, Matti


     

    Hi Matti,

     

    There is one problem in your script, but it should not have caused the error that you are seeing.

     

    Your custom script ends with response.redirect. This line should be removed, since this directive tells IIS to send an HTTP 302 to the client, which is exactly what you want to change. Just leave these two lines in your custom redirect script:

     

    Response.Status="301 Moved Permanently"
    Response.AddHeader "Location", orig_url
    
    

     

    I tried this on a UAG 2010 Update 2 server ( I believe, based on your code sample, that you are not yet using UAG Service Pack 1), and for me it worked as expected, changing the response status to HTTP 301, and getting the browser successfully redirected to the HTTPS trunk login page. I used the same naming convention like you did – Redirect_302_to_301.asp, for the custom redirect script in InternalSite/CustomUpdate.

     

    I’m not sure why are you getting an “internal error”. Make sure that in the UAG Management console, on the redirect trunk, you have specified the correct file name to be used. Maybe you have a typo in there?

     

    Regards,


    -Ran
    Saturday, January 8, 2011 12:34 PM