Hi,
I was just wandering if it is possible to set up a 301 redirect on /default.aspx ? Our SEO company say we need to do this but as the default.aspx is the only 'real' page within the website I'm not sure if it's possible. They say we need to redirect anyone from
www.mywebsite.com/default.aspx to
www.mywebsite.com
Can anyone please help?
Many thanks
I have inserted 301 code on PageEngine.cs class..
Marco
Hi Marco,
Any chance of seeing your 301 redirect code in PageEngine.cs?
Many thanks
My cuyahoga implementation include a StatusId for the site, because I want an entire site to be moved Permanently to the new domain..
So I have added these properties to the site object:
_currentSite.StatusId
_currentSite.RedirectUrl
if (_currentSite.StatusId == 301) // permanent redirect
{
if (string.IsNullOrEmpty(_currentSite.RedirectUrl))
throw new SiteNullException("Site status is 301 but no redirect url was provided for " + siteUrl);
string redirectUrl = _currentSite.RedirectUrl + HttpContext.Current.Request.RawUrl;
if (HttpContext.Current.Request.UrlReferrer != null)
{
//string deb = string.Format("301 Redirect: from '{0}' to '{1}'.", siteUrl, redirectUrl);
string deb = string.Format("{0}", (HttpContext.Current.Request.UrlReferrer == null ? string.Empty : HttpContext.Current.Request.UrlReferrer.ToString()));
//log.DebugFormat(deb);
Logger.Log(LogTypes.Redirect_301, deb); // custom logger
}
// actual 301 code
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", redirectUrl);
HttpContext.Current.Response.End();
}
Marco many thanks for the reply and code, it now works!
Ciao,
Jimmy