Spotlight Spotlight - 1 year ago 108
PHP Question

IIS php extension in URL

I'm migrating an Apache server to an IIS server.

Currently, in the Apache server, if we have a PHP page named, we can access it even without the final ".php" (i.e.

How to achieve a similar behavior in IIS?

Answer Source

With IIS8 and above Microsoft implemented the Web Platforms and you can download the module URL Rewrite from there (or just download it from their site).

After that, go to the IIS Service Management and click on "URL Rewrite"

URL Rewrite on IIS 8

At the right panel, you'll see a option to "Import rules.."

Import htaccess rules into IIS

Choose your .htaccess (that you currently have on your public_html) and click on the "Import" button.

This creates a file called web.config in the path of your site with a content that will look like the follwing:

<?xml version="1.0" encoding="UTF-8"?>
                <rule name="Redirect index.php" stopProcessing="true">
                    <match url="index\.php/(.*)" />
                    <action type="Redirect" url="{R:1}" appendQueryString="false" />

There are also some online services that may convert your .htaccess to web.config although I've tried a few and the import from the IIS Service Management works better.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download