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

Forums / Developing with Sitefinity / automatic 301 created when page name changed?

automatic 301 created when page name changed?

4 posts, 0 answered
  1. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    12 Nov 2009
    Link to this post
    Hi

    We've had an issue where users are changing page names, however, the manual links that point to the old page are breaking so we'd like to develop some functionality that does the following:

    if user changes page name
    - create a 301 redirect on the old name to point to the new name
    - the redirect must be a permenant 301 page moved redirect.

    would this be possible? if so how would we acheive this?

    thanks
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    12 Nov 2009
    Link to this post
    Hello Quade,

    Most probably you use an old version of Sitefinity where dynamic links are not implemented. I suggest that you should upgrade your project to Sitefinity 3.7 SP1.

    Another option could be creating a custom control  that you use to "manual links that point to the old page" and use the page ID instead of the name. Even if you rename the page the link will not be broken because you use IDs.

    sample code:

    protected void Page_Load(object sender, EventArgs e)
       {
           CmsManager manager = new CmsManager();
           ICmsPage p = manager.GetPage(pageID);
           HyperLink link = new HyperLink();
           link.Text = p.MenuName;
           link.NavigateUrl = p.StaticUrl;
           Controls.Add(link);
       }
     
       public Guid pageID
       {
           get
           {
               object obj = this.ViewState["pageID"];
               if (obj == null)
                   return Guid.Empty;
               return (Guid)obj;
           }
           set { this.ViewState["pageID"] = value; }
       }


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    12 Nov 2009
    Link to this post
    thanks ivan
    its 3.6 and its mainly due to links that people have been sent/printed on literature

    if they try and visit these pages they are getting 404's

    thanks

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    12 Nov 2009
    Link to this post
    Hello Quade,

    Then you can firstly use The replace tool to fix all url. After that apply the solution I suggest. Another option is creating an IHttpHandler that will get all renamed pages and make redirect. If you do not know which pages have been changed there is no way to fix the  urls.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
4 posts, 0 answered