URL rewriting examples in Apache, IIS and NGINX web servers.

[Source](https://gist.github.com/bramus/5332525)

# URL Rewriting in Apache, IIS and NGINX

## Apache

**.htaccess**

```apache
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
```

*Requires* [mod_rewrite](http://httpd.apache.org/docs/current/mod/mod_rewrite.html).
    
## IIS

**Web.config**

```xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Main Rule" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
```

*Requires* [URL Rewrite](http://www.iis.net/downloads/microsoft/url-rewrite)

## NGINX

**nginx.conf**

```nginx
location / {
    try_files $uri /index.php;
}
```