Api Subfolder error 404
Hi guys, i'm trying to configure restserver but when I navigate to the URL http://mydomain/api/example... etc. I get a 404 error.
Seems that every controller inside a subfolder can't be navigated....
I tried to create a new folder into /controllers/testfolder and I've put in it an index.html file but also this file can't be reached!
I've also reinstalled a clean codeigniter but the situation is the same!
Do you have any method with "_get" sufix in Example controller? If you navigate from your browser directly you only make GET request. If you want use other request and other methods than you should use some of REST clients like postman or similar.
Also, you have to check your routes definision in application/config/routes.php there you shoud have right route defined that you can reach controller and method (endpoint) from child directory. Provide more information or some code if you need instruction to make your setup work.
maybe u didnt delete index_page from config so try url like that : http://mydomain/index.php/api/example
Before I start, this is a great piece of code! Unfortunately, I am having the same issues with the Example for the past 4 hours. Following another site I was able to get an API working, but it is directly in my /controllers directory and not in the preferred /controllers/api/ directory. I want a sub directory, so I can version my API as website/index.php(if applicable)/api/v1/users.
Looking at codeIgniter's documentation, all they say about routing is the controller/method/parameters format and how I can set a route for the user of website/api/v2 = controller/method/parameters I would like to separate into sub folders, but it would work dumping everything in the controller directory. https://www.codeigniter.com/userguide3/general/routing.html
The site I followed to get a working API: https://seegatesite.com/codeigniter-tutorial-how-to-make-rest-api-server-and-client/
controllers.tar.gz routes.php.tar.gz
trouble shooting a bit I I discovered $route['api/apitest'] = 'apitest/test'; # works visiting /api/apitest/ $route['api/apitest/test'] = 'apitest/test'; # works visiting /api/apitest/test
so far
$route['api/example/users'] = 'example/users'; # does work visiting /api/example/users
as soon as I move the example.php file into the api directory and change the route to
$route['api/example/users'] = 'api/example/users'; # no longer works
it work fine for me. Let me know if any one need help in this.
//Rest API
$route['restapi/v1'] = 'restapi/restapi/v1';
//End Rest API