Exception to a global rule

Topics: Developer Forum, Project Management Forum, User Forum
Oct 17, 2011 at 2:13 PM


I have a global rule which changes the extension of all pages from .html to .aspx:

RedirectRule ^/(.+)\.html$ /$1.aspx [R=301]

But there is one folder which needs to be kept as .html. Do I use a RewriteCond for this or can I add it to the regex above?

Many thanks

Oct 19, 2011 at 11:42 AM

Sorry have now managed to get this to work by looking at an exception example and amending it slightly:

RedirectRule ^/((?!folder1|folder2).+)\.html$ /$1.aspx [R=301]

even managed to add other folders to the same exception.

Oct 22, 2011 at 3:43 PM

That's great - so it rewrites all URLs ending in .html, except for those URLs that appear in folder1 or folder2.