04-22-2019, 02:11 PM
I have some troubles with the redirect function.
I test my code with MAMP on my Mac. I don't want to set up multiple subdomains so I have multiple CI4 installations in subdirectories like this:
http://localhost:8888/ci4-test1/public/index.php
http://localhost:8888/ci4-test2/public/index.php
http://localhost:8888/ci4-test3/public/index.php
I submit a form to this URL:
http://localhost:8888/ci4-test1/public/index.php/some_controller/save/1
...after the data is updated in the database, I want to redirect to:
http://localhost:8888/ci4-test1/public/index.php/album/edit/1
But here is my problem. It redirect to this URL and gives a 404 not found error:
http://localhost:8888/some_controller/edit/1
In .env I set the baseURL like this:
app.baseURL = 'http://localhost:8888/ci4-test1/public/'
In my controller I do the redirect like this:
return redirect()->to('/some_controller/edit/' . $id');
What am I doing wrong? Why is the directory name 'ci4-test1/public' not in the destination URL?
I test my code with MAMP on my Mac. I don't want to set up multiple subdomains so I have multiple CI4 installations in subdirectories like this:
http://localhost:8888/ci4-test1/public/index.php
http://localhost:8888/ci4-test2/public/index.php
http://localhost:8888/ci4-test3/public/index.php
I submit a form to this URL:
http://localhost:8888/ci4-test1/public/index.php/some_controller/save/1
...after the data is updated in the database, I want to redirect to:
http://localhost:8888/ci4-test1/public/index.php/album/edit/1
But here is my problem. It redirect to this URL and gives a 404 not found error:
http://localhost:8888/some_controller/edit/1
In .env I set the baseURL like this:
app.baseURL = 'http://localhost:8888/ci4-test1/public/'
In my controller I do the redirect like this:
return redirect()->to('/some_controller/edit/' . $id');
What am I doing wrong? Why is the directory name 'ci4-test1/public' not in the destination URL?
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com