Search code examples
phpiis-7routessymfony1isapi-rewrite

Problem with Symfony routing with online project


I have a Symfony project on a Win XP / IIS 7 machine with Isapi rewrite installed. When I go to the frontend (my main) application, it seems that the routing simply doesn't work. I always end up on my default module/action. However, if I turnno_script_name = off (in the app's settings.yml file) then everything works fine. I also have an admin app as part of the project (which also has no_script_name = off) and this works fine as well. This seems like it should be a simple problem, yet we've been working on this for 4 hours now. Any help would be greatly appreciated, thanks.

Edit: I changed the front controller's environment to dev in order to use the debug toolbar and found that no matter what my URL looks like, it always says

Match route "homepage" (/) for / with parameters array ( 'module' => 'default', 'action' => 'index',)

No matter what I do, module always equals default


Solution

  • I've found the solution. I added this code to the top of my index.php

    $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
    

    I tried everything within the Symfony on IIS tutorial (http://trac.symfony-project.org/wiki/symfonyOnIIS) and nothing made a difference. If anyone else runs into this problem, please try adding the above code first before mucking with any settings or .htaccess rules.