Clean URLs with CakePHP and IIS

CakePHP works on IIS out of the box but it’s a pity the default setting is on querystring URLs. To serve clean URLs in CakePHP simply uncomment the following line in /app/config/core.php:

define ('BASE_URL', env('SCRIPT_NAME'));

By doing this CakePHP will direct each page request to the base script (by default thats index.php) and take charge of URL rewriting using the PATH_INFO environment variable.

This is ideal for serving CakePHP on IIS especially if you’re not using Helicon Tech’s ISAPI Rewrite and do not wish to fiddle about with configuring it or you’re on a shared environment and cannot touch the IIS settings.

Your CakePHP URLs will now look like:

Rather than:

Comments are closed.