Copied to clipboard

Flag this post as spam?

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


  • Yaya 11 posts 31 karma points
    May 12, 2011 @ 08:23
    Yaya
    0

    301 redirect not working.

     

     

    Hi,

    I've modifid the URLRewriting.config file in the /config folder, to the following :

     

    <urlrewritingnet xmlns="http://www.urlrewriting.net/schemas/config/2006/07">
    <rewrites>

     

     

    <add name="Redirect301"

    redirect="Domain"

    ignoreCase="true" rewriteUrlParameter="ExcludeFromClientQueryString"

    virtualUrl="^~/askDetails.aspx?hotel=1537"

    redirectMode="Permanent"

    destinationUrl="~/ProviderDetails.aspx?Prvdr=1234" />

     

     

     


    </rewrites>
    </urlrewritingnet>

    However, when I visit the URL, it just takes me to a default 404 error page:

     

     

    No umbraco document matches the url '

     

    http://www.apy.co.il/default.aspx?umbPage=/askDetails.aspx&hotel=1537

    '

     

     

    . How can I get this working - is the code above wrong?

    How  I solve this addition of "default.aspx"?

    Thanks all.

  • jason mitchell 11 posts 68 karma points
    May 12, 2011 @ 21:53
    jason mitchell
    0

    Here is a 301 redirect XSLT file I am using that essentially does a 301 redirect.  Create a macro from this with a parameter called redirectUrl

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet 
      version="1.0" 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:msxsl="urn:schemas-microsoft-com:xslt"
      xmlns:redir="http://www.umbraco.org/redir"
      xmlns:umbraco.library="urn:umbraco.library" 
      exclude-result-prefixes="msxsl msxml redir umbraco.library">
       
      <xsl:output method="xml" omit-xml-declaration="yes" />
        
      <xsl:param name="currentPage"/>
      
      <xsl:template match="/">
        <xsl:variable name="redirectUrl" select="/macro/redirectUrl" />  
        <xsl:if test="$redirectUrl != ''">
          <xsl:value-of select="redir:Redirect($redirectUrl)" />
        </xsl:if>
      </xsl:template>
      
      <msxsl:script implements-prefix="redir" language="C#">
        <msxml:assembly name="System.Web" />
        <msxml:using namespace="System.Web" />
        <![CDATA[
          /// <summary>
          /// Redirects a string site to a 301 Redirect
          /// </summary>
          /// <param name="url">String to redirect page to (usually passed via macro parameter)</param>
          /// <returns>String.Empty</returns>  
          public string Redirect(string url){
            System.Web.HttpContext.Current.Response.Status = "301 Moved Permanently";
            System.Web.HttpContext.Current.Response.AddHeader("Location", url.ToString());
            return String.Empty;
          }
        ]]>
      </msxsl:script>
    </xsl:stylesheet>

    Create a document type for your new 301 Redirects.  Inside the doctype create a textstring property and inside the template of the doctype add:

    <umbraco:Macro redirectUrl="[#PropertyAliasHere]" Alias="MacroAliasHere" runat="server">umbraco:Macro>
  • Yaya 11 posts 31 karma points
    May 15, 2011 @ 12:01
    Yaya
    0

    Hi,

    Thanks for your help.

    When you wrote "Create a document type for your new 301 Redirects" Do you mean that I have to open pages under the site content node for each old url page which I redirect?

Please Sign in or register to post replies

Write your reply to:

Draft