isapi/rewrite/ www.isapirewrite.com, an URL manipulation engine we'll use to replace Apache's mod_rewrite. Why this product? It seems to be mainly used on IIS, and the free lite version works for symfony. If you're used to something else, read on, there should be only one difference in the last chapter of this tutorial.

Install symfony, create your project, create your app.

Configure IIS

We'll consider two configurations options from now on:

In the first case, the webserver is only used for our symfony project, and the URL is something like http://myproject/. Assuming the directory in which you created the directory myapp is c:\myproject\, configure the root directory of your server to be c:\myproject\web (in IIS administration console).

The other option is to install our symfony project in a directory (may be virtual) of you server, the URL is in this case something like http://myserver/myproject/. In IIS administration console, create a new virtual directory on the root of your website for the directory c:\myproject\web.

Add a virtual directory in the main directory of your server. Name it sf and configure it to data\symfony\web\sf of your pear directory. If you installed php5 in c:\php5 with default configuration, the full path is C:\php5\PEAR\pear\data\symfony\web\sf.
Configuration of URL rewriting

We'll assume that isapi/rewrite is installed and running on your server. We have not yet bought it, so we only have one httpd.ini file to configure. The configuration depends on the options defined previously:

A note about logging

By default, IIS with ISAPIRewrite will not log the friendly names. To enable this, you must add the U (unmangle) flag to the last rule in your script. For instance, for the first example above, the last rule would be:

RewriteRule (.*) /index.php [L,U]

Configuring symfony

The last step is editing the file settings.yml located in the config directory of our symfony project (c:\myproject\myapp\config\ in our example). You won't be surprised to find a little difference between our two options, so:

Project as subfolder

Troubleshooting

The lite version of isapi/rewrite/ does not support per site configurations, and thus placing httpd.ini within the project web dir will do nothing. If you are using the free lite version, you can only place the rules defined above within the global configuration. This file is found in the installation directory of isapi/rewrite typically C:\Program Files\Helicon\ISAPI_Rewrite\httpd.ini. For sites with multiple virtual hosts, a global configuration file *may* cause problems on the other sites.

Important note: if you don't use isapi/rewrite/, the HTTP_X_REWRITE_URL may be wrong. You'll have to make a specific test to know how to configure symfony. Open the file myapp_dev.php (or whatever you named your application_dev.php) in the web directory of your project, and add these following lines on line 2 :

Configuring a symfony application in its own directory

A symfony project may contain several applications. In the default configuration, all the applications share the same css and uploads directory. Let's change this and create a specific directory for our application myapp. Considering our previous options, we'll manage to have these URLs : http://myproject/myapp and http://myserver/myapp. This time, there are no differences in the configuration between these options.

Create a subdirectory myapp in the web directory of your symfony project (to have in our case c:\myproject\web\myapp).

Copy the files index.php and myapp_dev.php in this directory, create there two directories named css and uploads.

In IIS administration console, create a new virtual directory on the root of your server named myapp. Configure this virtual directory to c:\myproject\web\myapp.