Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I know I can do it in IIS Manager, but I am looking for some programmatic way to do it. We need to do this for customer all the time. So it would be great if there's a programmatic way of doing so.

share|improve this question

1 Answer 1

There isn't a reliable programmatic way to automatically convert .htaccess files to web.config files because IIS's configuration is quite different from Apache's, as well as their configuration file formats.

There are some sites which claim to do automatic conversions, but the scope and accuracy of these are questionable.

You can however suggest that your client add an IIS module that uses standard regular expressions, since Apache's mod_rewrite module uses Perl Compatible Regular Expression vocabulary - see: Apache - mod_rewrite-Regular Expressions

One such module is ISAPI_Rewrite, which is written in pure C/C++. From their FAQ's:

ISAPI_Rewrite is a rule-based rewriting tool to rewrite requested URLs on the fly. ISAPI_Rewrite uses regular expression rules. With regular expressions you don't need to write a thousands check strings. The comparison and replace of URLs can be done with a few string patterns.

Using regular expressions for IIS should help to greatly speedup conversions of Apache RewriteRule's.

share|improve this answer
    
How bout sites like cbsa.com.br/tools/online-convert-htaccess-to-web-config.aspx and htaccesstowebconfig.com? I wonder how they do it. –  Yu Yu Aug 21 '13 at 11:13
    
I'd suggest testing the output of these before thinking about how they do it, or using them... –  dan Aug 21 '13 at 19:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.