Codeigniter routes not working. I have CodeIgniter setup under: .
Codeigniter routes not working its working fine on local. php I set $route ['404_override']='myerrorcontroller/amethod' and it works for undefined controller class. Testing Routes: After defining custom routes, make sure to test them in your browser to ensure they work as expected. Hello everyone, I'm facing an issue with routing in CodeIgniter 4. There is no need to define routes manually. The current url I can access is: http://localhost:8080/project/api/profile_test/ Dec 24, 2021 · CodeIgniter4 Installation Method Composer (as dependency to an existing project) Which operating systems have you tested for this bug? Windows Which server did you use? apache Database No response What happened? Redirecting routes not working with typical route Steps to Reproduce . The code was getting to the routing fine (I put a log_message call in just before the routing). After changing the routes order is a bit better but still, there are few bugs (?): cannot redirect to checkout/shoppingCart if that route has set the name. if I turned Auto Route to True. I try to allow all header origin and all API methods with Filter But, it's not working if AutoRoute turned to False. That means that the magic with your controllers will not work out of the box. php & make sure it's correct. Oct 21, 2020 · hi, i am developing a website. php is my Jan 3, 2019 · route not work in CodeIgniter for others routes than home Asked 6 years, 6 months ago Modified 6 years, 6 months ago Viewed 2k times Dec 22, 2015 · check the value of $config ['base_url'] in application/config/config. But this doesn't work on nginx/apache/xampp any server other than spark/php development server. However, it isn't getting to the controller. E function index ($variable = '') or what ever the default language is. Auto-Routing Improved is used when you don't want to register all routes. php only gets loaded when that module is "invoked", otherwise CI would have to load all route configurations from all modules in order to process each request (which does not happen). I used (:any) then it work. But when i uploaded it to windows server,only default controller working. In order to change that open your project at Oct 11, 2015 · i have a problem with my custom routes ! my routes codes works fine in CI3. Jun 3, 2019 · Welcome Guest, Not a member yet? Register Sign In CodeIgniter Forums CodeIgniter 4 CodeIgniter 4 Support Filter config not working with routes (?) Dec 24, 2021 · The codeigniter routes all call the controller functions fine and load the respective views and any functions on the page that use AJAX to call a controller function all work fine. Am I doing something wrong? Routes. Even though I have written the code in the controller properly to load a view, it Jul 15, 2019 · I'm very confused as the documentation for this is very straight forward and simple, I must be missing something. The controller and method should be listed in the same way that you would use a static method, by separating the class and its method with a double-colon, like Users Welcome Guest, Not a member yet? Register Sign In CodeIgniter Forums CodeIgniter 4 CodeIgniter 4 Discussion Routes Not Working On Live Host ?!!!!! Sep 14, 2023 · Hello, so in the past I always set up my apache (XAMPP) root directory to point to the public folder of my project. If i remove return (in this last test) exit work but redirect not work so i show a blank page Jul 17, 2020 · However the route does not work if you do not include the "/ (:any)" in the actual url. Sep 9, 2022 · When no defined route is found that matches the URI, the system will attempt to match that URI against the controllers and methods when Auto Routing is enabled. Jun 26, 2018 · I find this strange as I have "hardcoded" the route and placed it at the very top of routes. 3. php = LASTESTC. Apr 6, 2023 · In short it is only for backward compatibility. Aug 2, 2025 · Controllers and Routing URI Routing Controllers Controller Filters Auto Routing (Improved) HTTP Messages Request Class IncomingRequest Class Content Negotiation HTTP Method Spoofing RESTful Resource Handling Building Responses Working with Databases Modeling Data Managing Databases Library Reference Helpers Testing Command Line Usage Extending Dec 19, 2017 · I have setup a CodeIgniter site but only the default routing seems to be working. php players is the folder inside /admin and player. Just find it in the main page and prepend the github url with "raw" subdomain. Since its a windows server I don't know how to solve it on the server side of things. php file was working fine on the old server. Mar 15, 2023 · CodeIgniter4 - Controller or Method Not Found When Using Routing Groups and Subdirectory in Controllers Asked 2 years ago Modified 2 years ago Viewed 604 times Judging the title, first of all check if your server is running PHP using CGI/FastCGI or not (you could simply check that by phpinfo()). Steps taken: 1. A route takes the Route Path (URI path relative to the BaseURL. I have done all the required settings also but then also its not working. I tried: return redirect ()->route ('landing'); The current controller is rendered normally without redirect. Not working filter auth in dashboard route. " Jul 18, 2025 · This question shows research effort; it is useful and clear My codeigniter app was working fine in localhost/WAMP, but was unable to route and produced 404 not found errors when pushing to an AWS EC2 instance. In local host environment: 1. php` has a method ::details. getting "Not Found The requested document was not found on this server. " document root is httpdocs/public. Apr 4, 2023 · I am not sure it is your problem but it is where I would start - the /public dir is meant to be your DocumentRoot. 19. The "trailing slash in url problem" doesn't affect GET request Feb 12, 2018 · I have set up CI project through LAMP stack of which i have exactly the same problem as this guy CodeIgniter routing in Google App Engine I been through the post and no solution is found. php in my URL Only the default page loads No input file specified My app works fine locally but not on the production server The tutorial gives 404 errors everywhere : ( CodeIgniter Forums CodeIgniter 4 CodeIgniter 4 Support route_to not working with controller::method Oct 4, 2019 · Is this just me or this is not really working? please i am stuck at this problem. latestC. rewrite module was disabled all this while by running "sudo a2query -m rewrite", I don't know if this helps. The solution I've implemented, works with different scenarios that have problems on local host: HTTP 404 error, Windows 10 [::1] issue, Session not working on localhost issue, session class not working in Chrome issue. Unfortunately, I do not know the exact answer, but it must have been a carry over somewhere from one of the pre-release versions. 1. ‘foo/bar/ (:num)’ will not prevent controller Foo and method bar to be called with a non-numeric value if that is a valid route. However, I have now created a fresh CI4. There exist a problem called “CodeIgniter error 404”. htaccess file, save the file and reload your browser. Relevant portions of files: site/. Filter is not working in CodeIgniter 4. With the information provided, you would be better off asking your hosting provider for help, they usually have guys who can help you check your configuration. PS: I am using CodeIgniter 4 version Alpha2, PHP 7. php" I have Sep 30, 2014 · (:num) not worked my variable contain characters. Jul 10, 2021 · My CodeIgnater 4 is not recognizing POST routes when I try them in my shared hosting server on Hostinger. I have tested another way. I'm running the project locally with the PHP server installed and used by the PHP Tools. I am fairly new to CodeIgniter and finishing up my first project. My home page is displayed well, the page also reloads well when I click on "home" in my menu, on this side there is no problem, however when I want to access another page I have the message error following "Error 404". I want to test the default routes if working without any use of routes defined. 15. ajax (). For libraries like jQuery for example, it is not necessary to make explicit the sending of this header, because according to the official documentation it is a standard header for all requests $. If you've made changes based on my first comment, tell us what and what happened afterwards. 2, it just shows 404 for my custom routes ! my . Only the index route is working, and none of my other controller methods are accessible via URLs. Jan 16, 2014 · Custom route not working | Codeigniter Routing Asked 11 years, 4 months ago Modified 11 years, 1 month ago Viewed 2k times Jan 16, 2014 · Custom route not working | Codeigniter Routing Asked 11 years, 4 months ago Modified 11 years, 1 month ago Viewed 2k times Apr 13, 2016 · CodeIgniter Forums Using CodeIgniter Installation & Setup custom 404 and routing problems Oct 21, 2020 · hi, i am developing a website. i. If so, change the following in config. I was assuming it was a routing issue because other routes were working. Nov 7, 2019 · Bug: Routing group filter not working on nested or complex routes #2390 Jan 8, 2021 · Problem is that you're returning a Response object inside a function that is not known by the routing process of CI4. Jan 30, 2015 · I am using CodeIgniter 3 and am having problems getting the router to work in my development environment. This worked for me. php Blog. php to get this to work. It is easy to create Sep 22, 2022 · $routes->resource Please help me figure out what is the problem. Feb 15, 2022 · CodeIgniter Forums CodeIgniter 4 CodeIgniter 4 Support set404Override - JSON not working Dec 1, 2014 · PHP Collective php codeigniter codeigniter-2 codeigniter-url codeigniter-routing Follow this question to receive notifications edited Dec 1, 2014 at 0:53 Kyslik Sep 19, 2016 · `translate_uri_dashes` not working codeigniter route Asked 8 years, 9 months ago Modified 8 years, 9 months ago Viewed 4k times Just recently upgraded from Code Igniter 2. I'm trying to setup a menu, and using route config to load the proper content but from some reason it's not working. Nov 30, 2020 · CodeIgniter Forums Using CodeIgniter General Help CodeIgniter 3 routes don't work in HTTPS Feb 24, 2019 · I want to run the codeigniter project which I am currently working on in localhost I setup each and everythng accordingly Feb 27, 2022 · Postman is getting redirected for unknown reason and route not working/ Codeigniter 4 Asked 3 years, 8 months ago Modified 3 years, 8 months ago Viewed 1k times Jul 6, 2021 · What is the issue in above code. Wordpress are picking up every url, even the one that should be excluded. But the API is not working properly. Jan 29, 2023 · I'm using CI v4. But other metherds in that controller not worked Mar 16, 2015 · Working on codeigniter project. Got stuck with routes. My issue was solved from the answer from HERE htaccess works in localhost but doesn't work in EC2 instance (route to my admin page) {domain}/admin was producing 404 Thank you its working now i just replace the . php like this: Apr 27, 2017 · CodeIgniter routes not working Asked 7 years, 11 months ago Modified 7 years, 2 months ago Viewed 2k times Mar 26, 2021 · hi, thanks for help. 7. Controllers glue the models and views together. Your local host is on WAMP - which windows does does not care about file cases. 2. when I add index. I have CodeIgniter setup under: May 1, 2012 · CodeIgniter routing not working Asked 13 years ago Modified 7 years, 1 month ago Viewed 14k times Hello everyone, I'm facing an issue with routing in CodeIgniter 4. The auto-routing feature in CodeIgniter 3 was exceptionally user-friendly! Due to the discontinuation of PHP 7 support, I am currently evaluating the use of the latest CodeIgniter 4 framework. e. Everything after the proceeding / is truncated. 2 it is working without a problem I cannot change all my Rest API to use /1 in front of the url for put because my Application is already launch. I mapped my routes, It is working fine without placeholders, but once i add placeholder, it disorganizes my view. . /public should not appear in your URL. Mar 3, 2025 · CodeIgniter is a lightweight and powerful PHP framework for building web applications. Since when are you using this function for routes? Feb 21, 2015 · I'm using Codeigniter with HMVC, I Have a sub controller with a name differed from Module name - modules - manage - controllers - manage. I started coding this site with 4. 4 PHP vers May 25, 2021 · Do you have a default set for your input variable for Cerca::index. 0-alpha, and have updated the base code with every release. here is the htaccess on public. It's your server configuration. Here's the thing: the module's routes. The same routes. The API is writting in PHP using CodeIgniter, if I write the dis Mar 15, 2024 · CodeIgniter Forums CodeIgniter 4 CodeIgniter 4 Support Cors policy filter not work Aug 2, 2025 · This section describes the functionality of Auto Routing (Legacy) that is a routing system from CodeIgniter 3. Expected Output should redirect on new typical route Anything Sep 21, 2020 · At first I think it because second route with segment, but it turns out after I delete the second route I still get the same result. php: Dec 17, 2013 · codeigniter codeigniter-2 codeigniter-url codeigniter-routing asked Dec 17, 2013 at 5:15 user1275378 Anyone who wants to redirect a route forcefully, You can do it by redirect('<route>','location',304)->send(); Redirect function creates RedirectResponse object which is consumed by CI runtime and the class is extended upto MessageInterface. I want to access en/company/login through en/login, so how do I define routes then? Right now routes code looks like this: // URI like '/en/ Mar 20, 2019 · I know I work because I have played with it last year and it works. php before controller name in URL, it works fine. However, before I put it up on my hosting site I would like to clean up the URL's using the routes. Aug 2, 2025 · URI Routing Controllers Controller Filters Auto Routing (Improved) HTTP Messages Request Class IncomingRequest Class Content Negotiation HTTP Method Spoofing RESTful Resource Handling Previous Next May 3, 2016 · @Saty when i try your example i get the some Not Found The requested URL /post/delete/1 was not found on this server. You'll have to use your main application's routes. php yet it doesn't get executed for some reason? Any input and / or help appreciated. I have to deploy an old SPA and API to google app engine, so I've split them into 2 services. Jan 2, 2020 · Codeigniter routes works in local server. htaccess, so I'm fairly certain that's not it. 2 to Code Igniter 3. It allows flexible URL. Once you have added these lines to your . Dear All, Could any one please help ? I am using CI4 to build rest API. This means that those URLs never need to hit Codeigniter at all. Now, if we run `php spark serve`, with the localhost:8080 it works perfectly. tv. Did you place the Ion-Auth directory in the root, so beside the public and the application directory? Nov 8, 2021 · Home. php May 27, 2020 · You're right. Please let me know is i am m Sep 24, 2020 · (09-23-2020, 06:05 PM) nc03061981 Wrote: You should learn about Routes - route->get: receive get data (use for echo a view or Submit Get form) - route->post: receive post data (use for Submit Post form) If you only use route get, you will not receive post data from Submit form Learning CI4 from my works, from errors and how to fix bugs in the Feb 21, 2022 · I am working in code igniter and getting url rewriting issue. So change your Mar 25, 2013 · I have a single page web site so all routes should lead to the default router. Aug 29, 2022 · Just started a new project with CodeIgniter and after installation with composer I noticed the following warning in Routes. Aug 23, 2022 · Can anyone tell me: Do I have to declare all of my controllers in Routes. This is my base url: $config['base_url'] = 'http://mysite. I have controller that I route to using routes. 1 but after upgrading to CI3. Ok i will Jun 29, 2020 · CodeIgniter Forums CodeIgniter 4 CodeIgniter 4 Support Problem with routes if Controller is in a subfolder Pages (2): 1 2 Next » Sep 21, 2025 · Learn how to create a custom CodeIgniter 404 Page Not Found error page with controller, route, and view setup to improve UX and reduce bounce rate. I think the main difference (which I haven’t updated the documentation for that sorry) is that starting from Codeigniter 4. Auto Routing automatically routes HTTP requests based on conventions and execute the corresponding controller methods. I. My error controller class is called. Unfortunatly not work. It's not even going to controller Jan 8, 2022 · For software routing to work, instructions are prescribed to the web server to redirect the processing of requests to the front controller in the absence of a file or directory. I noticed that the mod. The homepage works however any other URL is routed to this default_controller even though other routes are Nov 17, 2020 · It doesn't show the 404 page for non-existent routes too. 2 and later they’ve changed the default routing from “auto” to “off”. Sep 14, 2023 · This will tell Apache to rewrite all requests to the index. when I deploy to var/www/html of server, the routes not working as expected. Apr 30, 2023 · I have tried removing the get ('/', 'Main::index") route and the first request then fails, so routing seems to be working I have tried many routes for the static page Documentation states that the (:any) placeholder should return the remainder of the URI string, but in my implementation, I only ever get the next segment. 4 project, and moved all of my code into it, updated the config folder to reflect the settings I had Oct 18, 2016 · I want to do routing in code-igniter and i have done the below steps also but it is not working. php in my URL Only the default page loads No input file specified My app works fine locally but not on the production server The tutorial gives 404 errors everywhere : ( Aug 2, 2025 · I have to include index. php Sep 26, 2024 · CodeIgniter Forums CodeIgniter 4 CodeIgniter 4 Support Routing Not Working - Only Index Route Accessible Oct 26, 2016 · CodeIgniter Forums Using CodeIgniter General Help Custom routes not working Nov 17, 2020 · It doesn't show the 404 page for non-existent routes too. php The `Blog. Everything works fine with Aug 2, 2025 · I have to include index. cz'; This is a rewrite base Dec 2, 2022 · My issue is Auto Routing knows there's a "Login" route, but when I try to access the Dashboard without being signed in, CI4 tells me "The route for "login" cannot be found. Note the link in the example is changing as they have many branches. You aren't using the pages segment in your URL, therefore the routing for that module never gets Mar 13, 2013 · I've put into production a codeigniter website and I'm getting a strange behaviour that I'm not able to debug. Controllers – routes are linked to controllers. The tes CodeIgniter Forums CodeIgniter 4 CodeIgniter 4 Support Auto Routing (improved) post method not working Hey, I have previously developed websites using CodeIgniter 3, and deploying them on IIS 10 presented no issues. I can reach /blog/details-page without errors. I have a Controller named Project. When you use it, use it carefully not to create vulnerabilities. php Controllers are not working with lowercase Asked 6 years, 8 months ago Modified 6 years, 8 months ago Viewed 458 times Sep 28, 2022 · For the previous version codeigniter 4 Version 4. Here’s what I’ve done so far: app/Config/Routes. Is there something wrong with the code? setautoroutes not detected routes improved I just got into CI4 from a CI3 background but I'm finding it difficult to get routes to display the appropriate view. Apr 15, 2021 · CodeIgniter Forums CodeIgniter 4 CodeIgniter 4 Support Nested routes not working Apr 24, 2023 · Routes not working properly in codeigniter 4 Asked 2 years, 6 months ago Modified 2 years, 6 months ago Viewed 504 times May 27, 2020 · You're right. Aug 8, 2020 · CodeIgniter helps you to create a page called “404 error” which helps in getting user engagement without any diversion. One is Defined Route Routing, and the other is Auto Routing. php != latestc. I put the rewrite rules in my virtual host's <Directory> and tested it on an apache2. Oct 30, 2018 · And a file relating to this controller does not exist and hence the 404 File not found exception is thrown. The only way I have been able to make it work is using two routes: routes in codeigniter 4 | codeigniter 4 routes not working | routes in ci4|codeigniter 4 custom routes If this Programming Video Help U : Like 👍 | Comment 💬 | Subscribe : / @yesuus Apr 12, 2023 · What does "still not working" mean? What did you change? What is your project's Document Root? "It redirects to the default page" - do you mean a real redirect, with a 300 or 301 http code, or do you just mean the route shows the index page? Edit your question, add details. But now I am working on several projects at the same time, so I set my DocumentRoot back to D:/xampp/htdocs/ In my project I set the base url inside the App. shoppingCart route name - this is not practical if we manage redirection from eg database cannot redirect to another redirect setting redirection code is not working, always get 307 despite Nov 27, 2024 · CodeIgniter Forums CodeIgniter 4 CodeIgniter 4 Support Multi-level routing filters not working Jun 27, 2023 · I'm having hard time to configure nested groups in CI 4. If you're using Apache, that means DocumentRoot "/path/to/your/public", if you're using nginx root /path/to/your/public. echo "test"; return redirect ()->route ('landing'); exit; This test show "test" in page but exit as redirect, is ignored. 4 Affected module (s) routing Expected behavior, and steps to reproduce if appropriate I'd expect that any controller set under my modules folder to be automatically routed like the ones that are on the app folder. I'm using mod rewrite and all the pages points always to the home (default route) unl Jun 9, 2012 · I bet you the issue is due to case-sensitivity on files. I don't think the built-in server uses . I'm using PHP Tools For Visual Studio 2019 by DevSense. htaccess with the right one Jul 11, 2019 · Still not working using filters How do you do guys to redirect to login if user it's not logged without repeating condition in all Controllers::index? Sep 18, 2017 · I believe that I already did all the important thing to set up the custom route in codeigniter but I still don't know why I always get 404 error. 0 I am going to assume those are URLs to static files, not dynamically generated Javascript or CSS files. Any help? I have a application with Codeigniter in controllers folder I have front/ admin/players/players. Mar 28, 2019 · Codeigniter routes. php - Route Definitions May 21, 2019 · I'm not sure if you can do a urlencode for the route path. While it provides a structured development environment, users often encounter issues such as routing errors, database connection failures, session misconfigurations, and performance bottlenecks. Jan 18, 2018 · Routes not working codeigniter Asked 7 years, 10 months ago Modified 1 year, 8 months ago Viewed 14k times Aug 2, 2025 · CodeIgniter has two kinds of routing. php file that CodeIgniter provid Welcome Guest, Not a member yet? Register Sign In CodeIgniter Forums CodeIgniter 4 CodeIgniter 4 Discussion Routes Not Working On Live Host ?!!!!! Aug 2, 2025 · CodeIgniter has two kinds of routing. Auto-Routing Legacy is a legacy system and dangerous, but if you don't use Controller Filters (including CSRF protection) at all, the risk is low. php in Codeigniter 4? I can't seem to get a controller to work unless I add it directly to the "Routes. 4. Understanding these challenges and applying best practices ensures a smooth CodeIgniter development experience. But, I cannot protect API route if I turned AutoRoute to FALSE my frontend cannot send POST method with Cross Origin Resource Sharing to my API. conf file of Apache. g. I don't know which web server you are using, but most, if not all, can be configured to route those URLs to a static folder and never touch your PHP engine. Website is plaster. CodeIgniter 4 version 4. php in the url. php = latestc. php: // The Auto Routing (Legacy) is very dangerous. CodeIgniter will route the URLs according to your custom configurations. With Defined Route Routing, you can define routes manually. Remove the . php but on your production server (which I'm guessing is a LAMP) - case sensitivity DOES matter i. I have tried several cha Aug 28, 2020 · Problem resolved. It a forcing for us using checkout. Nov 27, 2022 · I believe the main issue that you have though is with the routes. htaccess is works fine and correctly, si Nov 26, 2020 · Controllers under modules should be part of the routing without the need to create a lot of routes for it. 0. CodeIgniter Routing matches the URL to the pre-defined routes. htaccess, remove or rename the file. php Jul 31, 2015 · I have the following problem with CodeIgniter. /) on the left, and maps it to the Route Handler (controller and method Home::index) on the right, along with any parameters that should be passed to the controller. I used "Option 1" of the rules + the !mod_php5 rule at the end. But in codeigniter you can make it use have the index. htaccess file: RewriteEngine on RewriteCond $1 !^(index Feb 7, 2018 · Not sure if this is caused by CodeIgniter URL routing issue or something to do with httpd. Dec 24, 2021 · The codeigniter routes all call the controller functions fine and load the respective views and any functions on the page that use AJAX to call a controller function all work fine. php - views - das Apr 18, 2020 · It's not a CodeIgniter problem then. 4 with proxypass to php-fpm. This is how I put my routes resource in config routes : I have a "routing" problem on CodeIgniter 4. 2. 2 Web server Apache 2. Oct 22, 2020 · Then its a server issue. Dec 8, 2023 · CodeIgniter Forums CodeIgniter 4 CodeIgniter 4 Support How to setup a single route with optional argument Pages (2): 1 2 Next » Pages (2): 1 2 Next » Jan 14, 2022 · I am new to CI4 and i've been battling this for weeks now. php != LASTESTC. If you want the redirect to happen, you have to return your redirect()->to('blabla') inside your index function because that is the main function you called with your router Jan 9, 2020 · Describe the bug The function setAutoRoute to FALSE not working CodeIgniter 4 version develop Affected module(s) CodeIgniter\\Routes\\Routes Context OS: macOS 10. Route rules are not filters! Setting a rule of e. shoppingCart route name - this is not practical if we manage redirection from eg database cannot redirect to another redirect setting redirection code is not working, always get 307 despite Oct 12, 2022 · I've been tried follow the the tutorial from the ci4 website how to enable auto routes but it's still not working. If not route match is found then CodeIgniter throws a page not found exception. Default controller is working and other controllers showing 404 error. php in all urls so you can at least have a working site. Do not use . Jun 28, 2024 · Routing – routing is responsible for responding to URL requests. Expected Output should redirect on new typical route Anything Dec 24, 2021 · CodeIgniter4 Installation Method Composer (as dependency to an existing project) Which operating systems have you tested for this bug? Windows Which server did you use? apache Database No response What happened? Redirecting routes not working with typical route Steps to Reproduce . php All your controllers must be LOWERCASE for Codeigniter. I'm trying to configure the access to routes passing thru a group of filters to authenticate and validate the data that i'm using in the May 15, 2013 · No, the unrouted URL doesn't work. It automatically routes an HTTP request, and executes the corresponding controller method without route definitions. In config/routes. php file, which will then handle the routing. htaccess and in your app config set it to have the index. Everything else works as expected and the POST routes work fine on my local server. bjlsegzvfolinybtzliwqhufytueqwlvpqmxsjayesvbbucrxpjjvnjgyrwbfutjxjpj