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'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

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"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
            </files>
        </defaultDocument>
        <rewrite>
            <rules>
                <rule name="Silex Front Controller" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
share|improve this answer

First Method :

install web platform installer from : http://www.iis.net/downloads

after that find the urlrewrite and add to iis, than you can find url rewrite section in iis.

You can create new rule or import from .htaacess file via url rewrite.

Second and Easy Method :

Open iis and select related website, go to errors section and find 404 error. double click on it. change url : /index.php Now all unknown request redirect to index.php

Good Luck.

share|improve this answer

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.