A
A
Andrew2015-10-16 19:42:45
PHP
Andrew, 2015-10-16 19:42:45

Slim: how to create routes in different subdirectories?

I apologize in advance for the chaotic question, I don’t even quite understand how to formulate it normally, but I’ll try ...
There is a root directory with index.php and the code:

require 'libs/Slim/Slim/Slim.php';

\Slim\Slim::registerAutoloader();

$app = new \Slim\Slim();

$app->config('debug', true);

$app->get('/users/:one', function ($one) {
  echo "The first parameter is " . $one;
});

$app->run();

Here everything works fine. Then there is a test subdirectory in the root with the index.php file and exactly the same code (except require 'libs/Slim/Slim/Slim.php'; - I corrected the path here), which does not work.
I can't figure out why it doesn't work and how to fix it. The .htaccess file is at the root of the framework.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Belikov, 2015-10-19
@igorbelikov

If I understand correctly, then you have the following structure:
/app/slim/...
/app/index.php
/app/test/index.php
/app/.htaccess
If yes, then you most likely need to look at .htaccess and the problem in it because it probably does not allow to reach test.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question