I've always used Apache for all my web development work and I'm struggling to get my head around IIS. I've got an API that re-routes all requests to one particular file: 'api.php', how would I do the following in IIS:

RewriteEngine on
RewriteRule ^/.* /api.php

My server only allows web.config files to achieve this so I have no access to IIS manager, or anything of that nature. I'm using IIS 7.5.


2 Answers 2


The design pattern you are using is called the "front controller" -- a central entry point for handling requests.

Here is a website that shows how to implement that pattern with various webservers. Here is the configuration they recommend for IIS in the web.config file:

<?xml version="1.0"?>
                <clear />
                <add value="index.php" />
                <rule name="Silex Front Controller" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                    <action type="Rewrite" url="index.php" appendQueryString="true" />

First Method :

Install web platform installer from:

Find the urlrewrite and add to IIS, then you can find URL rewrite section in IIS.

You can create a new rule or import from .htaccess file via URL rewrite.

Second and Easy Method :

  1. Open IIS and select related website
  2. Go to errors section and find 404 error.
  3. Double click on it.
  4. Change URL to /index.php

Now all unknown requests redirect to index.php.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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