Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > How to do Url Rewrite on Kentico? View modes: 
User avatar
Member
Member
Leandro Brito - 9/26/2011 3:39:51 PM
   
How to do Url Rewrite on Kentico?
Hi guys,

I need do a url rewrite configuration and need some help.

The url is:
www.mysite.com/country/state/rentals.aspx?a=1&b=2&c=3
It need call KenticoCMS/rentals.aspx page.

I can configure the path of url with country name and state name, but I don't know how and where configure the rewrite to "rentals.aspx". I read some articles and threads and tested some codes in Global.asax, but without sucess.

Is necessary use url rewrite module in IIS ?
Where should I put the code?
Do they have some example?

Thanks!

User avatar
Member
Member
Leandro Brito - 9/27/2011 5:53:11 PM
   
RE:How to do Url Rewrite on Kentico?
Hi, I got a solution, but I would like knows if it is a nice solution.
My code:


#region Custom Redirect

string strCustomPath;
string strCurrentPath = Request.Path.ToLower();

// Search the page to fire the rewriter
if (strCurrentPath.ToLower().IndexOf("rentals.rt") > -1)
{
string parametros = string.Empty;

// Search the parameters by querystring
if (URLRewriter.CurrentURL.IndexOf('?') > -1)
parametros = URLRewriter.CurrentURL.Substring(URLRewriter.CurrentURL.IndexOf('?'));

// new path
strCustomPath = string.Format("/rentals.aspx{0}", parametros);

// Rewrite the URL
Context.RewritePath(strCustomPath);
}

#endregion


The url will be www.mysite.com/country/state/rentals.rtl?a=1&b=2&c=3 but the page called is /rentals.aspx.

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 9/28/2011 4:12:15 PM
   
RE:How to do Url Rewrite on Kentico?
Hi,

While that solution might work fine for your purposes, I believe it would be easier to use custom url path for a rentals.aspx page (defined normally in the content tree).
Please see following documents in the DevGuide about URLs:
http://devnet.kentico.com/docs/devguide/url_format_and_configuration.htm
and
http://devnet.kentico.com/docs/devguide/multiple_document_aliases.htm
You may need to configure your application (through web.config) to allow custom url extensions as indicated in the articles (with link to the configuration instructions).

The query parameters will be preserved during the redirection that will happen e.g. when you allow "Redirect document aliases to main URL", as described in the first linked document.
Hope this will help.

Regards,
Zdenek

User avatar
Member
Member
Leandro Brito - 10/3/2011 3:03:19 PM
   
RE:How to do Url Rewrite on Kentico?
Hi,

My solutions does not work in live site with IIS 7.
I deployed the site copying the files for inetpub/wwwroot/kenticoCMS but the rewriter of url not work.
The site returns the error "404 - File or directory not found."
Is necessary some configuration on IIS? I'm using pipeline mode classic and framework 4.0.

Thanks.

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 10/9/2011 11:36:39 AM
   
RE:How to do Url Rewrite on Kentico?
Hi,

You might have bad application mapping,..
also for rewriting to work correctly in IIS7, you will need to use Integrated pipeline mode.

Regards,
Zdenek C.