Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 354
NAMAssist Avatar asked Oct 27 '25 12:10

NAMAssist


1 Answers

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.

like image 141
Philosoraptor Avatar answered Oct 29 '25 06:10

Philosoraptor