0

I am moving a php web application from Linux to IIS 7. What I need to do is hide everything that says php, so the url extension and links primarily. I don't think there are any other things that need to be hidden because they are non-displaying already. Any suggestions?

Pratik
  • 11,534
  • 22
  • 69
  • 99
bmbaeb
  • 520
  • 1
  • 8
  • 15

5 Answers5

2

To do this on my server I had to first: install the URL Rewrtie Module http://www.iis.net/downloads/microsoft/url-rewrite

And then I had to add a web.config file with this XML (this works for removing the .php, if added, as well as adding the .php invisibly to the URL):

    <?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Redirect .php extension" stopProcessing="false">
                    <match url="^(.*).php$" ignoreCase="true" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{URL}" pattern="(.*).php$" ignoreCase="false" />
                    </conditions>
                    <action type="Redirect" url="{R:1}" redirectType="Permanent" />
                </rule>
                <rule name="hide .php extension" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="true" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        <add input="{REQUEST_FILENAME}.php" matchType="IsFile" />
                    </conditions>
                    <action type="Rewrite" url="{R:0}.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
jasondeegan
  • 119
  • 1
  • 8
2

The next best thing to native Apache mod_rewrite is probably this

Here's more info on Microsoft Mod Rewrite 2.0:

http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/

paulsm4
  • 114,292
  • 17
  • 138
  • 190
2

Have a look at the expose_php option in php.ini, as well as the suggested mod_rewrite.

Shi
  • 4,178
  • 1
  • 26
  • 31
2

ISAPI_Rewrite is a good alternative to mod_rewrite on Apache; we've used it on a number of projects deployed on Windows+IIS. The syntax is the same as mod_rewrite and it supports all of the features I've ever had to use on Apache mod_rewrite.

There's a free version you can use that applies the rules to every site on the server; if you're creative you can use RewriteCond to limit them to particular domains mapped to sites. The paid version is worth the cost as well if that's in your budget.

http://www.helicontech.com/isapi_rewrite/

Jeremy Clifton
  • 533
  • 5
  • 17
2

On IIS 7 use the native IIS URL Rewrite module. ISAPI_Rewrite is your best alternative if deploying on IIS 6 or earlier.

The URL Rewrite Module can also import most of the mod_rewrite rules out of .htaccess if that helps as well.

Start here http://iis.net/urlrewrite

Mark Brown
  • 8,113
  • 2
  • 17
  • 21