301 Redirect to External Page
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!
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);