I am new in Codeigniter and my route not working. Route are exists in route file. but when io hit url I get not found error. My Route file is
$route['default_controller'] = "home"; $route['404_override'] = 'error/page/e404'; $route['translate_uri_dashes'] = FALSE; $route['([a-z]+)/testimonials/index'] = 'testimonial/home/index'; $route['([a-z]+)/all_auctions'] = 'all_auction/all_auctions/index'; $route['([a-z]+)/all_products'] = 'all_product/all_products/index'; $route['([a-z]+)/page/contact-us'] = 'page/contact/index'; $route['([a-z]+)/page/(.+)'] = 'page/page/index/$2'; $route['([a-z]+)/auctions/winners/(:num)'] = 'auctions/winners/index/$2'; $route['([a-z]+)/feed'] = 'feed/index/index'; $route['([a-z]+)/feed/winners'] = 'feed/index/winners'; $route['([a-z]+)/feed/winners/(:num)'] = 'feed/index/winners/$2'; $route['([a-z]+)/auctions/closed/(.+)-(:num)'] = 'auctions/winners/details/$3'; $route['([a-z]+)/all_auctions/(:num)'] = 'all_auction/all_auctions/index/$2'; $route['([a-z]+)/all_auctions/upcoming_auctions'] = 'all_auction/all_auctions/upcoming_auctions'; $route['([a-z]+)/all_auctions/upcoming_auctions/(:num)'] = 'all_auction/all_auctions/upcoming_auctions/$2'; $route['([a-z]+)/auctions/upcoming_auction/(.+)-(:num)'] = 'auctions/details/upcoming_auction_detail/$3'; $route['([a-z]+)/auctions/(.+)-(:num)'] = 'auctions/details/index/$3'; $route['([a-z]+)/products/(.+)-(:num)'] = 'products/details/index/$3'; $route['([a-z]+)/referer/(.+)'] = 'referer/index/$1'; $route['([a-z]+)/landingpage/(.+)'] = 'landingpage/index/$2'; $route['([a-z]+)/(:num)'] = 'home/index/$2'; $route['404_override'] = 'error/page/e404'; $route[ADMIN_LOGIN_PATH] = 'login/admin'; $route[ADMIN_DASHBOARD_PATH] = 'dashboard/admin'; $route[ADMIN_DASHBOARD_PATH.'/profile'] = "dashboard/admin/profile"; $route[ADMIN_DASHBOARD_PATH.'/logout'] = 'login/admin/logout'; $route[ADMIN_DASHBOARD_PATH.'/forgot'] = 'login/password'; $route[ADMIN_DASHBOARD_PATH.'/reset'] = "login/admin/reset"; $route[ADMIN_DASHBOARD_PATH.'/newsletter/subscriber'] = "newsletter/subscriber/index"; $route[ADMIN_DASHBOARD_PATH.'/newsletter/subscriber/(:num)'] = "newsletter/subscriber/index/$1"; $route[ADMIN_DASHBOARD_PATH.'/newsletter/subscriber/(.+)'] = "newsletter/subscriber/$1"; $route[ADMIN_DASHBOARD_PATH.'/newsletter/template'] = "newsletter/subscriptiontemplate/index"; $route[ADMIN_DASHBOARD_PATH.'/newsletter/template/(.+)'] = "newsletter/subscriptiontemplate/$1"; $route[ADMIN_DASHBOARD_PATH.'/([a-zA-Z_-]+)/(.+)'] = '$1/admin/$2'; $route[ADMIN_DASHBOARD_PATH.'/reload'] = "login/admin/reload"; // URI like '/en/about' -> use controller 'about' $route['^en/(.+)$'] = "$1"; $route['^en$'] = $route['default_controller']; $route['app/([a-z_]+)'] = "app/$1"; $route['app/([a-z_]+)/([a-z_]+)'] = "app/$1/$2";
and I am trying route
http://localhost/en
and I get this error How can I solve this issue
Advertisement
Answer
Mostly this cause by URL navigates with index.php
.
In config.php
$config['base_url'] = 'http://stackoverflow.com/'; $config['index_page'] = '';
And in .htaccess
RewriteEngine on RewriteCond $1 !^(index.php|assets|image|resources|robots.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Read more : Set up the base url in codeigniter