Install PHPCG on NGINX or Microsoft IIS server

Add the admin/.htaccess rewrite rules to your server config file.


How it works

All the requests sent to the admin folder are redirected to admin/index.php, which creates the main routes.

This is done with admin/.htaccess on apache servers.

Here's how to make the same redirections on NGINX or Microsoft IIS servers.

NGINX Server

  1. Open your nginx configuration file (nginx.conf)
  2. Add the following rules:
    location /admin/ {
        try_files $uri /admin/index.php;
    }

If you instal PHPCG in a subfolder, of course add your subfolder before /admin

Microsoft IIS Server

  1. Open your Server configuration file (your web.config file in the root directory of your website)
  2. Add the following rules:
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <rewrite>
          <rules>
            <rule name="Imported Rule 1" stopProcessing="true">
              <match url="^admin/(.*)$" ignoreCase="false" />
              <conditions>
                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
              </conditions>
              <action type="Rewrite" url="admin/index.php/{R:1}" appendQueryString="true" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration>

Back to Knowledge Base