Search code examples
asp.net-mvcurl-rewritingurl-routingiirf

URL Rewriting multiple folders to one folder


I'm using IIRF on IIS6/Server03 with an MVC app in the root of the server and a virtual directory for the wordpress blog/cms. I'd ideally like the urls as follows...

  • domain.com/
  • domain.com/wpcategory/ -> rewritten from domain.com/blog/wpcategory/
  • domain.com/wpcategory/wparticle/ -> rewritten from domain.com/blog/wpcategory/article/

Thanks to the ISAPI Plugin I can use modrewrite esque code...

## REGIONAL GUIDES ##
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /guides /guides/index.php [L]

But bar writing guides to guides etc I'm struggling to work out what or even if I can actually do that or if it needs to be in a subfolder domain.com/wp/wpcategory/article (which currently works fine. Essentially looking to rewrite the base to the root of the site without stuffing MVC... Fun?


Solution

  • The solution for ISAPI_Rewrite 3 is:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(wpcategory/.*)$ /blog/$1 [NC,L]