Search code examples
c#regexurl-rewritingdotnetnuke

How can I transform this url with REGEX?


I have a dynamic web app built using DotNetNuke that uses the following url format:

/SeoDummy.aspx?template={VAR1}&keywords={VAR2}

My user friendly url format is like this:

http://domain.com/.{VAR1}/{VAR2}

I am really terrible with REGEX and need to somehow detect when the user friendly url is requested and rewrite it with the dynamic web app url. I have tried the following, but It is not catching it on the site, it is just 404'ing:

.*/^([^/]+)/([^/]+)/?$

I am sure you that know regex will find my attempt silly, but regex is my kryptonite!

Thanks for any help that can be offered.


Solution

  • Since you are using some custom url,I guess regex would be better than using URI class


    In your regex you have misplaced ^..The regex should be

    ^https?://domain[.]com/[.]([^/]+)/([^/]+)/?$