Welcome Guest, Not a member yet? Register   Sign In
Redirected whenever adding trailing / on the URL
#1

(This post was last modified: 02-28-2020, 06:57 AM by xdev. Edit Reason: Clarification )

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/CodeIgni...ssues/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.
Reply
#2

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB