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?
-
Look into mod_rewrites on IIS: http://stackoverflow.com/q/60857/561731 – Naftali Aug 08 '11 at 20:29
5 Answers
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>

- 119
- 1
- 8
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/

- 114,292
- 17
- 138
- 190
Have a look at the expose_php option in php.ini
, as well as the suggested mod_rewrite.

- 4,178
- 1
- 26
- 31
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.

- 533
- 5
- 17
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

- 8,113
- 2
- 17
- 21