General - .NET User Groups General issues with editing, development and graphic design.
Kentico CMS for .NET User Groups > General - .NET User Groups > Redirection Problem View modes: 
User avatar
Member
Member
shailendra.dubey-gatesix - 3/31/2009 2:00:57 AM
   
Redirection Problem
Hello Forum members

We are using Kentico for Dot Net websites. We are facing a problem

Kentico will make some default pages for a website

http://www.xyz.com/default.aspx
http://www.xyz.com/Default.aspx
http://www.xyz.com/home.aspx
http://www.xyz.com/Home.aspx
http://www.xyz.com/default.aspx/default.htm
http://www.xyz.com/default.aspx/home.htm

All these are different URLS, but landing on Home page. We need to redirect all these pages to http://www.xyz.com.

But we are not getting any solution to this problem, we need this redirection because this cause Canonical URL's issue.

Please help us out.

Thanks & Regards
Shailendra Dubey

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 4/7/2009 7:33:05 PM
   
RE:Redirection Problem
Hi Shailendra,

you could check for these URLs in App_Data\Global.asax.cs, in Application_BeginRequest method.

If the URL matches one of the variations, you could call Response.Redirect("http://www.xyz.com/");

The code itself may look like:
...
//add also other strings into the condition
if (URLRewriter.CurrentURL.ToLower().Contains("home"))
{
int urlEnd = CMSContext.RawUrl.LastIndexOf("/");
Response.Redirect(CMSContext.RawUrl.Substring(0, urlEnd));
}
...

In the surrounding code:

...
// Rewrite the path to get to the proper page
switch (URLRewriter.RewriteUrl())
{
// Document page
case URLRewritingResultEnum.PathRewritten:
{
if (CMSContext.ViewMode == ViewModeEnum.LiveSite)
{
//add also other strings into the condition
if (URLRewriter.CurrentURL.ToLower().Contains("home"))
{
int urlEnd = CMSContext.RawUrl.LastIndexOf("/");
Response.Redirect(CMSContext.RawUrl.Substring(0, urlEnd));
}
// Check parameters
...

Hope this will be useful.

Regards
Zdenek Cetkovsky

User avatar
Member
Member
shailendra.dubey-gatesix - 5/8/2009 11:57:20 PM
   
RE:Redirection Problem
Thanks for the suggestion, i will use it & get back to u.