Welcome Guest, Not a member yet? Register   Sign In
Custom routes not working
#1

I'm trying to build a custom route. I'd like to map /account-overview to the AccountOverview class method processRequest() so I entered this as my /application/config/routes.php:


$route['default_controller'] = 'accountOverview/processRequest';   // just to test the controller when it would not come up
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['account-overview'] = 'accountOverview/processRequest';


The page comes up when I enter just localhost - so the page itself is functional but when I try the /account-overview URL I get NOT FOUND. I've tried adding a second part to the URL like /account-overview/page and mapping that but all I get is 404 NOT FOUND. I even tried using /accountOverview/processRequest and still got NOT FOUND. What is wrong? This is the most basic function of a framework if this doesn't work then I can't use codeIgniter. How can I execute class AccountOverview method processRequest  ??? Ideally with a friendly URL ???

I've checked and there are no .htaccess files anywhere that could mess with the URL. I do not have a _remap function anywhere. There's nothing in the log files. How do I debug the framework itself?The bug would be _parse_routes of /system/core/Router.php - I can start debugging from there. Something tells me i'm going to extend yet another /system/core class. I'd prefer not to. Any ideas?
Reply
#2

Quote:This is the most basic function of a framework if this doesn't work then I can't use codeIgniter.

Rest assured it does work, and has for a decade now.

Do you have an .htaccess file to remove the index file? It sounds like you haven't done that, yet. If that's the case, then you should be able to access the site at /index.php/account-overview.

You'll probably also need to set translate_uri_dashes to TRUE.

And just to confirm, you have a controller at /application/controllers/AccountOverview.php right?
Reply
#3

Ah - the .htaccess file was the problem - I over-wrote it setting up /dev and /dist static asset directories. I knew it had to be something glaringly obvious that I was missing. So I needed to add back index.php to the URL or the lines to .htaccess that say if it isn't a file or a directory go to index.php - thanks!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB