Rectangle 27 0

Is the error page you're seeing the CodeIgniter error template or a generic server error? That error string sounds very much like you are using Apache or Nginx (or whatever main webserver you use) and its actually not even resolving to your CodeIgniter app at all, but searching for a PHP file that doesn't exist. You'll probably need to use mod_rewrite or something like that to make that URL point at the CodeIgniter install.

Otherwise, your implementation doesn't look completely wrong: you probably need to make sure main.php is the default route as well.

Thats probably it, I believe we use Nginx. Like I said I'm not the backend web guy here so I'm not all too familiar with our webserver or even codeigniter for that matter. I'll have to discuss this with our lead web developer tomorrow and see if he can figure out why it's pointing to a file that doesn't exist. Thanks for your help!.

Actually there was a line of code in the My_Controller file that was forcing it to use the first segment of the uri as a class name, I pulled that out and it works fine now.

php - Codeigniter Dynamic Routing to single controller - Stack Overflo...

php codeigniter content-management-system custom-routes
Rectangle 27 0

I need the "users" can be dynamic. I already created a routes and it work for me can you check if this is the best way.

$route['api/v1/(:any)/([a-z 0-9~%.:@_\-]+)/(:any)'] = "$1/index/$2/$3";
$route['api/v1/(:any)/(:num)'] = "$1/index/$2";
$route['api/v1/(:any)'] = "$1/index";

php - Optional CodeIgniter Routing Parameter With Dynamic Controller -...

php codeigniter rest url-rewriting routing
Rectangle 27 0

The CMS writes a file into the codeigniter config dir, lets call it dynamic_route.php The written file is analog to the normale route.php config file.

$route['(\w{2})/(\w{2})/URL_PART_FROM_CMS/?(.)?'] = 'CONTROLLER_CHOSEN_IN_CMS';
$route['default_controller'] = "content";
$route['404_override'] = '';
// include file
include('dynamic_routes.php');

Every time the cms changes sth. the dynamic file is rewritten. This makes it very dynamic without any performance impact.

php - Codeigniter dynamic routing (or loading one controller using dif...

php codeigniter dynamic routing
Rectangle 27 0

Your application will only look for the page name in your views if you tell it to. Your catch-all controller method should be checking the database for a valid page name, and then regardless of which pages validate, loads the same view (albeit with different data passed to the view).

Using an (:any) catch-all route is perfectly fine. Your controller code somewhere is what's throwing you off. Update your post with the code if you continue to struggle.

php - Codeigniter Dynamic Routing to single controller - Stack Overflo...

php codeigniter content-management-system custom-routes
Rectangle 27 0

You could look into remapping the method being passed instead of using routes:

function index(){
    // my default method
}
function _remap($method){
    if ($method == 'en'){
        $this->english();
    } else if($method == 'de') {
        $this->german();
    } else {
        $this->index();
    }
}

function english(){
    // my english method
}

function german(){
    // my german method
}

Well, the problem is, as far as I understand it, this will not give me different controllers, right? I would rather have it, that if I go to domain.com/kontakt or /contact I get to the same controller. The remapping only works inside a function, right? Any other suggestions?

remapping only works inside of the same controller, yeah. it also looks like you may an extra node in your route definition since you don't have to account for the domain in routes: $route['(\w{2})/contact/?(.)?'] = 'contact'; $route['(\w{2})/kontakt/?(.)?'] = 'contact';

Well, no that is actually for the language part, my url goes like this. domain.com/en/contact. So any other ideas to get something like this working?

you shouldn't be putting your domain in the route - $route['([a-z]{2})/contact'] = 'contact' and $route['([a-z]{2})/kontakt'] = 'contact';

it is not the domain, it is the language part. Why would I not use it in the route so it is ignored? I do not see the reason this.

php - Codeigniter dynamic routing (or loading one controller using dif...

php codeigniter dynamic routing