I have created this http handler:
public void ProcessRequest(HttpContext context)
{
//write your handler implementation here.
string RequestedPage = context.Request.Url.Segments[1].ToString().ToLower();
string queriedRequest = "category1-page";
bool doesUrlContain = RequestedPage.Equals(queriedRequest);
if (doesUrlContain)
{
context.Response.Redirect(context.Request.Url.Segments[0] + "production" + context.Request.Url.Segments[2]);
}
}
Which should handle every call to "test-page" or its subpages and redirect by changing part of URL. However it is not really clear for me how to register this handler in my umbraco project. Maybe someone can provide step by step tutorial?
This handler should run on occasions when user is using old link to page or subpage and redirect to correct page as root page is changed.
Locally I use iis7 for development.
Thanks in forward.
In your web.config, you need to add a handler that refers to your class where you define the http handler, something like this:
<system.webServer>
<handlers>
<add name="MyHandler" path="test-page" verb="*" type="MyNamespace.MyHandlerClass" resourceType="Unspecified" preCondition="integratedMode" />
The http handler must be defined in the same assembly as the web.config.