Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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" />
share|improve this answer

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.

share|improve this answer

Your Answer


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.