tags:

views:

4410

answers:

6

I've set a website up. If I try and click on a link such as register I get the following error:

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

The links are generated using

<?php 
    print link_to( 'Register', 'register/index' ); 
?>

And I have a 'register' module in apps/frontend/modules/register.

I'm quite new to Symfony, any help is appreciated!


routing.yml:

# default rules
homepage:
  url:   /
  param: { module: home, action: index }

default_index:
  url:   /:module
  param: { action: index }

default:
  url:   /trevelyan.alumni/:module/:action/*
+1  A: 

I think that your problem is that you're running symfony out of a "sub-site" instead of directly off of the "root" url (http://www.dur.ac.uk/trevelyan.alumni instead of http://www.dur.ac.uk/). I think the easiest solution would be to add trevelyan.alumni to the front of all your urls in routing.yml.

For example, for the default route, instead of

default:
  url: /:module/:action/*

use

default:
  url: /trevelyan.alumni/:module/:action/*
Steven Oxley
The problem seems to be that I'm using a 'virtualdocuments' handler (no .htaccess allowed) so any requests that are not to a file that exists (e.g. /register/) get sent to virtualdocuments/index.php. I've made this just require /index.php but it still doesn't seem to work - same error as above.
James Inman
# default rules homepage: url: / param: { module: home, action: index } default_index: url: /:module param: { action: index } default: url: /trevelyan.alumni/:module/:action/*
James Inman
so wait - virtualdocuments/index.php requires symfony's index.php? Maybe symfony is not parsing the route correctly because it is not what you're actually seeing in the browser. It might be useful to try to find out exactly what route symfony is getting.
Steven Oxley
+1  A: 

Read Steven Oxley, but try this as well :

Check you have at least an action class in your module dir with the proper name (symfony is case sensitive, and this is very tricky).

If you do, check that the default action (in the module config files) is one of the action class in your module.

Don't forget to clear cache every time you change a config file.

e-satis
A: 

Just a quick note, for the routing change(s) to take effect, you must run symfony clear cache:

./symfony clear-cache
deepwell
+1  A: 

I managed to fix this by editing the symfony controller files to use the $_SERVER variables to pick a module from, if one was not found.

James Inman
glad you were able to resolve the problem.
Steven Oxley
A: 

you should remove a dot from your matching url for route because of default routing rules

change your default route to:

default:
  url: /trevelyan_alumni/:module/:action/*

and that should work. note that dot(.) is replaced with _

deresh
A: 

I had upgraded from symfony 1.2 to 1.4, and was having this problem. At the end of the day, basically the config files have all changed enough to the point that routing somehow broke. Going through the app config files and comparing / updating them against the "new app" templates found in lib/vendor/symfony/lib/config/config (or where ever you are keeping symfony) fixed this issue.

Craig W