Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Connie DeCinko 931 posts 1160 karma points
    Jan 10, 2017 @ 23:32
    Connie DeCinko
    0

    Url Tracker conflict with 302 redirect

    I'm posting here in the general area as the author of Url Tracker is taking a break and not available to answer questions. I'm hoping someone has seen this and/or can assist.

    I upgraded our site from Url Tracker 1.x to 3.x and most of the package appears to be working. However some links are not being redirected from their old URL to their new URL. I cannot seem to find a pattern as it happens with both manually entered items and auto entered. I did however come across what appears to be some code (or an old package) that I have on our pages that does a redirect based on a doc property.

    This extra field on every document may be empty or may contain an external URL. The code below checks for the existence of a value and then redirects if one is found. Both work correctly without the other, but together they cause Url Tracker to send requests to the 404 page.

    Contents of 302Redirect.xslt:

        <xsl:output method="html"/>
    
        <xsl:param name="currentPage"/>
    
        <msxsl:script language="VB" implements-prefix="vb">
            <msxsl:assembly name="System.Web"/>
            <![CDATA[
         Public Function Redirect(url As String)
         System.Web.HttpContext.Current.Response.Status = "301 Moved Permanently"
         System.Web.HttpContext.Current.Response.AddHeader("Location", url.ToString)
         Return ""
       End Function
       ]]>
        </msxsl:script>
    
        <xsl:variable name="redirectUrl" select="/macro/redirectURL" />
    
        <xsl:template match="/">
            <xsl:if test="string($redirectUrl) != ''">
                <xsl:value-of select="vb:Redirect($redirectUrl)"/>
            </xsl:if>
        </xsl:template>
    
    </xsl:stylesheet>
    
  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Jan 11, 2017 @ 09:22
    Chriztian Steinmeier
    0

    Hi Connie,

    There's at least a couple of reasons that you should probably get rid of that macro; but I think you need to figure out why you end up on a 404 for those that doesn't work.

    My initial instinct tells me the ones that doesn't work must be because they're duplicated but one of them goes to an actual non-existing URL?

    Hope that helps,

    /Chriztian

  • Connie DeCinko 931 posts 1160 karma points
    Jan 11, 2017 @ 15:43
    Connie DeCinko
    0

    I agree, there are probably now better ways to do this than the macro, and one of these days I need to upgrade our templates to MVC and clean up all these old macros.

    Since Url Tracker doesn't support linking to external pages, any better ideas how to do so? For example, we have a placeholder content node/page for job postings that is actually hosted by a third party at careers.azbar.org. I need the ability to transparently redirect from www.azbar.org/careers to careers.azbar.org. I have similar cases where I need content authors to be able to create these redirects so they need to do so via Umbraco.

  • Connie DeCinko 931 posts 1160 karma points
    Jan 11, 2017 @ 15:45
    Connie DeCinko
    0

    In addition, that macro was created back when our site was on Umbraco 4. I just found this article telling how to do this a different way in Umbraco 6. Any experience with this method?

    http://www.theoutfield.co.uk/blog/2013/10/handling-external-urls-in-umbraco-6

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Jan 11, 2017 @ 19:47
    Chriztian Steinmeier
    0

    Yes - I've done something very similiar to that — since you've already got the redirectURL property on all nodes that should redirect, I'd say it's a perfect solution for you on this site.

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft