开发者

Symfony 1.4 routing issues only when using index.php and mod_rewrite

The most succinct way of summarizing the problem at hand:

  • Development is over, and everything was run against frontend_dev.php during development and testing

    This means that all URLs were: server.com/frontend_dev.php/module/action/parm

  • Moving to production means switching environments, and thusly using index.php instead

    server.com/index.php/module/action/parm

  • Part of moving to production is using mod_rewrite under Apache2 to make the “index.php” part of the URL vanish, but still be functioning

    server.com/module/action/parm is still routed against index.php

  • The URLs are indeed appearing w/o the index.php part, but symfony routing is now complaining:

    ie, server.com/goals which routes to goals/index

    -- perfectly fine using frontend_dev.php or index.php as an explicit controller

    server.com/index.php/goals

    -- using no explicit controller (via rewrite):

    [Tue Dec 14 12:59:51 2010] [error] [client 75.16.181.113] Empty module and/or action after parsing the URL "/goals/" (/)

I have verified the rewrite is indeed routing to index.php by changing the rewrite to something that doesn’t exist:

[Tue Dec 14 13:05:43 2010] [error] [client 75.16.181.113] script '/opt/www/projects/adam/web/index2.php' not found or unable to stat

I have tried rerouting to frontend_dev.php, but only am provided with more debug information from symfony, none 开发者_高级运维of which is helpful:

404 | Not Found | sfError404Exception Empty module and/or action after parsing the URL "/goals/" (/).

stack trace

1. at () in SF_SYMFONY_LIB_DIR/controller/sfFrontWebController.class.php line 44 ...

2. at sfFrontWebController->dispatch() in SF_SYMFONY_LIB_DIR/util/sfContext.class.php line 170 ...

3. at sfContext->dispatch() in SF_ROOT_DIR/web/frontend_dev.php line 13 ...

I have tried the using the RewriteBase option in .htaccess, but that does not help any, nor changing the true/false in the configuration line of the controllers

I hope this provides enough to understand why we’re confused, and able to direct us to a resolution.

Following is the current .htaccess and index/frontend configuration lines

Index.php:

$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false);

Frontend_dev.php:

$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'dev', true);

.htaccess:

RewriteEngine On

# uncomment the following line, if you are having trouble # getting no_script_name to work #RewriteBase /

# we skip all files with .something #RewriteCond %{REQUEST_URI} ..+$ #RewriteCond %{REQUEST_URI} !.html$ #RewriteRule .* - [L]

# we check if the .html version is here (caching) RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f

# no, so we redirect to our front web controller RewriteRule ^(.*)$ index.php [QSA,L]


I had similar issue and setting 'AllowOverride' to ALL for Symfony's WEB folder in Virtual Host's config sorted out this problem.


Welcome to Stack Overflow.

Maybe you're confusing the "index" route with "index.php"?

These URLs should theoretically all work.

server.com/frontend_dev.php/goals/index  
server.com/index.php/goals/index  
server.com/goals/index  
server.com/goals

I can't remember if the trailing slash, like server.com/goals/, works or not. There's a gotcha there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜