Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# jimmyfingers 9/1/2009 9:56 AM
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
# markfind 9/9/2009 10:26 AM
I have inserted 301 code on PageEngine.cs class..

Marco
# jimmyfingers 9/14/2009 4:42 PM
Hi Marco,

Any chance of seeing your 301 redirect code in PageEngine.cs?

Many thanks
# markfind 9/18/2009 11:35 AM

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();
			}
# jimmyfingers 9/18/2009 12:15 PM
Marco many thanks for the reply and code, it now works!

Ciao,
Jimmy