简体   繁体   中英

Using Htaccess files on iis (windows 10)

I cannot find any information on how to perform URL Rewriting on IIS (windows 10). I develop websites on windows but have a linux server which uses a htaccess file for URL Rewriting.

The issue here is, I find it far too time consuming to manually enter rules into iis with the standard url rewriter. You can't just write them out in a text document like you can on a Linux server with htaccess files!?

Is there some way to use a htaccess file, web.config file, or ionic's isapi (or other) url rewriter on iis (windows 10) to write out all of my websites url rewriting rules? It seems that none of those software packages have support for this operating system/the latest IIS.

Thanks!

All rules for the IIS URL Rewrite module are stored in text files, either your local web.config or the global ApplicationHost.config file. You can also use a custom config file like rewrite.config and include it in your web.config like:

<system.webServer>
    <rewrite>
      <rules configSource="rewrite.config" />
    </rewrite> 
</system.webServer>

IIS url rewriting is the same for all IIS Version since 7.0 on Server 2008 and nothing had changed in Windows 10, there are lots of resources about it out there.

I had the same issue, but fortunately there is a handy shortcut in the IIS URL Rewrite 2.1 module that converts .htaccess files directly into the equivalent web.config;

  1. In IIS, double-click on the URL Rewrite module
  2. In the Actions pane, click 'Import Rules'
  3. Paste the contents of your .htaccess file into the 'Rewrite rules' text box
  4. Viola, your .htaccess rules are converted into IIS web.config rules

There is an article here: https://blogs.msdn.microsoft.com/azureossds/2015/04/23/converting-apache-htaccess-rules-to-iis-web-config-using-iis-manager-for-azure-websites/ that provides an illustrated step-by-step guide to the process. The article is specifically aimed at Azure, but I use IIS on Windows 10 for localhost dev and it works just fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM