This project is read-only.

Help - how do I preserve [rewrite] requested URLs with Orchard

Topics: General, Troubleshooting, Writing modules, Writing themes
Feb 6, 2016 at 7:12 AM
Edited Feb 8, 2016 at 8:29 AM
Hey guys, I'm desperately trying to redirect and rewrite some URLs with no luck in my project.

Currently I'm using:
FilterProvider, IActionFilter [OnActionExecuting(ActionExecutingContext filterContext)] modify the request, along with filterContext.HttpContext.Response.Redirect("newUrl", true) to redirect to the location I want.

This all works, but doesn’t sort the main issue I'm trying to amend, and that is, how to keep the original request URL in the browser the same? I have attempted IIS Rewrite rules, but any 'rewrite action-type' seems to break the config file and my project displays blank [redirects behave normally]? Is there a better way or does anyone know how I could solve this?

I feel Routes could be the key, but don't know Orchard [at all] enough to intercept the request / amend it, then send it off to #what area# / #action# etc. for Page's that I have created in the dashboard, as in - I have no idea how Orchard handles this or how I could?

Really would appreciated any help or suggestions you may have, thanks a lot in advance, PP
Feb 23, 2016 at 9:25 AM
It sounds like the IIS URL Rewrite Module is the way to go, because that enables you to bind any incoming URLs to other URLS that should serve the request, which will have the effect of leaving the URL in the browser unchanged (which won;t happen with redirecting from your action filter). Make sure that module is installed and enabled in IIS, otherwise you'll get a configuration error, which is what I suspect to be the cause when you saw the configuration error.