CodeIgniter Forums
Redirected whenever adding trailing / on the URL - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Redirected whenever adding trailing / on the URL (/showthread.php?tid=75639)



Redirected whenever adding trailing / on the URL - xdev - 02-28-2020

Hi,

I installed CI 4 appstarter (via composer) yesterday and I'm using xampp while developing an app on Windows. I encountered a problem whenever I access a URL with  trailing slash onthe browser.

http://localhost/test-app/public/post - is okay
http://localhost/test-app/public/post/ - whenever there's a trailing slash my browser redirecting me to http://localhost/post.

On my .env

PHP Code:
app.baseURL 'http://localhost/test-app/public/' 

Routes.php

PHP Code:
$routes->get('/post''Post::index'); 


There's an issue that was already close (https://github.com/codeigniter4/CodeIgniter4/issues/2445)
However I'm still get redirected.

I also noticed that when I do echo base_url(); it will show the URL without trailing slash. On CI 3 there's a trailing slash.

I tried php spark serve and it's working well. No redirects whenever there's a trailing slash.


RE: Redirected whenever adding trailing / on the URL - marqone - 02-28-2020

There are a few threads about problems running CI4 in anything other than the root of the domain; I am going to guess and say this might be part of that problem since you put it in a folder under the root of your domain.