301 Redirect to External Page

Posted by Community Admin on 03-Aug-2018 14:29

301 Redirect to External Page

All Replies

Posted by Community Admin on 03-Sep-2014 00:00

I'm running Sitefinity 7 on IIS 7.  I currently have a bunch of documents in my Sitefinity library that will be moved to a different domain.  I need to create 301 redirects for the Sitefinity document URLs to the new domain.    How do I create a redirect to an external domain for a former Sitefinity URL?  Is this done using IIS URLRewrite? Or something within Sitefinity itself?

Thanks!

Posted by Community Admin on 08-Sep-2014 00:00

Hi Alycia,

You can handle the redirects as in any traditional ASP.NET application in the Global.asax file or by defining rewrite rules in the web.config file. I found the following articles related to redirecting in ASP.NET which might be useful to you:

1. http://stackoverflow.com/questions/10673303/301-redirect-in-asp-net-4-0
2. http://www.sitefinity.com/developer-network/forums/deployment--/redirects
3. http://www.sitefinity.com/documentation/documentationarticles/installation-and-administration-guide/create-a-project/creating-and-running-projects-on-iis/using-url-rewrite-for-seo

For example, in order to redirect your users from a page of your site domain.com to a different domain you can check the URL in Application Begin Request method in the Global.asax file and redirect to the new location:

var RedirectString = "newdomain.com/file.pdf";
if (HttpContext.Current.Request.Url.ToString().Contains("domain.com/docs/default-source/pdfs/file.pdf"))
    Response.StatusCode = 301;
    Response.AddHeader("Location", RedirectString);

The code above checks if the url is "domain.com/docs/default-source/pdfs/file.pdf" the user is redirected to new location of the file as specified in the RedirectString variable.

I hope the above information helps.

Regards,
Sabrie Nedzhip
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed