+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Redirect URL

Redirect URL

9 posts, 0 answered
  1. subodh
    subodh avatar
    24 posts
    Registered:
    25 Mar 2009
    17 Apr 2009
    Link to this post
    Hi,

    Currently we are shifting a website to other domain like(http://www.example.com/hello.html TO http://www.new.com/hello.aspx) .
    So here, the requirement is to redirect to the NEW DOMAIN URL when user types the old one.

    I know it can be done using 301 permanent redirect.

    But do u provide any way to implement it in sitefinity.

    Thanks
    Subodh.

  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    20 Apr 2009
    Link to this post
    Hello Subodh,

    Sitefinity can only follow the requests to its domain, and not on the domain of your old site. In order to redirect your old site (which I assume, is not a Sitefinity project), you could can:

    - create a new HttpModule which redirects the requests to the new site, in case your old site is running on IIS.
    - use a redirect entry set in the httpd.config in case you are running apache.

    Is your old web site a Sitefinity project?

    All the best,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. subodh
    subodh avatar
    24 posts
    Registered:
    25 Mar 2009
    22 Apr 2009
    Link to this post
    Hi,
    Sorry for not explaining in a clear way!

    Here is a scenario

    We are shifting a project which is completely done with the HTML Pages to SITEFINITY.
    The requirement is:
    Suppose in their HTML Website they have a URL(http://ecom/default.html) to access default.html page.

    As we are shifting it to SITEFINITY, here the URL Changes like
    "http://ecom/services/migration/default.aspx" and DOMAIN remains same but the path changes.

    so the requirement is if user types http://ecom/default.html we should REDIRECT to  http://ecom/services/migration/default.aspx.

    Thanks
    Subodh.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Apr 2009
    Link to this post
    Hi subodh,

    Try using HttpModule. Add the code to App_Code folder.

    sing System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
     
    /// <summary> 
    /// Summary description for MyHttpModule 
    /// </summary> 
    public class MyHttpModule :IHttpModule 
        public MyHttpModule() 
        { 
            // 
            // TODO: Add constructor logic here 
            // 
        } 
        #region IHttpModule Members 
     
        public void Dispose() 
        { 
             
        } 
     
        public void Init(HttpApplication context) 
        { 
            context.BeginRequest += new EventHandler(context_BeginRequest); 
        } 
     
        void context_BeginRequest(object sender, EventArgs e) 
        { 
            HttpContext mycontext = HttpContext.Current; 
            if (mycontext.Request.RawUrl.Contains("/domain/Default.html")) 
            { 
                string redirectUrl = mycontext.Request.Url.ToString().Replace("/domain/Default.html""domain/default.aspx"); 
                mycontext.Response.Redirect(redirectUrl); 
            } 
        } 
        #endregion 
     


    Register your httpModule

    <httpModules> 
          <add name="MyHttpModule" type="MyHttpModule, App_Code" /> 


    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. subodh
    subodh avatar
    24 posts
    Registered:
    25 Mar 2009
    23 Apr 2009
    Link to this post
    Thanks for quick reply Ivan

    Services                          Contanct
        migration                        client
        behavior purchases         local Hello
                      product                    Log    
                     
    The above is a site menu with hierarchy of pages services is a parent to its child pages(migration......)

    suppose in old site the url to access to product page is http://example/product.html but in new one the order is  http://example/Services/behavior/Product.aspx.

    Again in older one to access Log page in contact the url is http://example/Log.html but in new one the order is http://example/Contact/local/Log.aspx


    So the question is if user types both the older site url for product and log pages, will the above code(which you sent)  redirects to the desired url to newer site and in future what if path changes to some other directory.

    like
    http://example/future/menu/Product.aspx

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    23 Apr 2009
    Link to this post
    Hi subodh,

    You can check whether there is ".html" in the url. If so, remove .html and replace it with .aspx

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. subodh
    subodh avatar
    24 posts
    Registered:
    25 Mar 2009
    23 Apr 2009
    Link to this post
    Hi Ivan,

    I think i didn't make my question clear

    As you said that, we can check in the url whether is extension is .htm or not and replace it with .aspx that is fine, but the url path(in my above reply) is different in new site .

    Like for instance your solution will work if
    the url does not have any hierarchical path

    http://example/product.html can be changed to http://example/product.aspx(which is easy)

    but what if the page in different hierarchy like http://example/services/migration/product.aspx then it wont work and this is for only one page, there would be many pages with different parent pages.

    But in old site they didn't follow the same hierarchy they have just the domain name/pagename.html for each and every page like
    http://example/product.html
    http://example/log.html
    http://example/migration.html

    but the above pages have different parent pages in the new site.
    so how to access those pages when the above url is given.

    Thanks









  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    23 Apr 2009
    Link to this post
    Hi subodh,

    You need to create your own logic depending on the new hierarchy for your website.
    Possible ways are - using HttpModule or rewrite rules.

    Here is a sample of url rewriting

    We are creating a rule for the following scenario

    old path- domain/home.html
    new path- domain/services/test/home.aspx

     <telerik> 
        <urlrewrites> 
          <!-- Add your rule elements here --> 
          <rule> 
            <url>/[^/]+\.html</url> 
            <rewrite>/service/$1/$1\.aspx</rewrite> 
          </rule> 
        </urlrewrites> 

    Note that AdvancedUrl rewriter is turned of by default. It have to be enabled. You may have many rules, but they are executed form the top to the end.  For more information about the rules and using the rewriter check our User Manual, URL Rewriting

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. Gabe Sumner
    Gabe Sumner avatar
    440 posts
    Registered:
    09 Sep 2007
    28 Apr 2009
    Link to this post
    Here is another thought.  Sitefinity allows you to easily add additional URLs to an existing page:

    http://www.sitefinitywatch.com/blog/09-01-06/Easy_URL_Management_in_Sitefinity.aspx

    So, let's say you have the following page:

    http://example/services/migration/product.aspx

    You can easily add an additional URL to this page:

    http://example/product.aspx

    Notice the *.aspx extension on this additional URL.  I know this isn't what you want, but use it anyway.  :)  If you use an *.html extension on this URL, Sitefinity won't handle the URL and will throw a 404.

    Ok, we now have an *.aspx version of the old *.html URL working.  As you described above it's very easy to do an extension conversion from *.html to *.aspx using an HttpHandler or the AdvanceUrlRewriter:

    http://www.sitefinitywatch.com/blog/09-01-08/URL_Rewriting_with_Sitefinity_s_AdvancedUrlRewriter.aspx

    http://www.sitefinitywatch.com/blog/09-01-09/URL_Rewriting_using_a_Custom_HttpModule.aspx

    Basically you're using a hybrid of two URL management techniques to handle these old *.html URLs.  Thoughts?

    Gabe Sumner
    http://www.sitefinitywatch.com/
Register for webinar
9 posts, 0 answered