CodeIgniter Forums
problem slash at the end of 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: problem slash at the end of url (/showthread.php?tid=78186)

Pages: 1 2


problem slash at the end of url - Halim - 12-10-2020

Hello,

I'm trying this url on my project:  http://localhost/ci4.0.4/about   
Result: works fine

but when I added slash at the end of the url like:
http://localhost/ci4.0.4/about/

Result: it redirect to http://localhost/about

This is my setup:
$baseURL = 'http://localhost/ci4.0.4/';

I'm using: wamp server under Windows10

any advice, Thanks in Advance,


RE: problem slash at the end of url - sammyskills - 12-11-2020

Can you change the folder name from ci4.0.4 to something else without the dots ?


RE: problem slash at the end of url - Halim - 12-11-2020

(12-11-2020, 01:38 AM)sammyskills Wrote: Can you change the folder name from ci4.0.4 to something else without the dots ?

I did, but still not working!!


RE: problem slash at the end of url - sammyskills - 12-11-2020

Okay.
Can you share what you have in your .htaccess file?


RE: problem slash at the end of url - Halim - 12-11-2020

(12-11-2020, 11:05 AM)sammyskills Wrote: Okay.
Can you share what you have in your .htaccess file?

Sure, 
By the way, I moved the index.php and htaccess from public folder to the root

This is my htaccess and Routes files  (I attached my htaccess)


My Routes:

/**
* Auth routes
*/
$routes->match(['get', 'post'], 'login', 'Auth\LoginController', ['filter' => 'noauth']);
$routes->match(['get', 'post'], 'password/forgot', 'Auth\PasswordController::forgot', ['filter' => 'noauth']);
$routes->match(['get', 'post'], 'register', 'Auth\RegisterController', ['filter' => 'noauth']);
$routes->get('logout', 'Auth\LogoutController::index');

/**
* App routes
*/
$routes->get('/', 'HomeController::index', ['filter' => 'auth']);
$routes->get('/home', 'HomeController::index', ['filter' => 'auth']);
$routes->get('/about', 'AboutController::index', ['filter' => 'auth']);


RE: problem slash at the end of url - sammyskills - 12-11-2020

Quote:By the way, I moved the index.php and htaccess from public folder to the root

Just to confirm... Have you updated the default $pathsPath = realpath(FCPATH . '../app/Config/Paths.php'); to match the current directory structure?


RE: problem slash at the end of url - Halim - 12-11-2020

(12-11-2020, 11:36 AM)sammyskills Wrote:
Quote:By the way, I moved the index.php and htaccess from public folder to the root

Just to confirm... Have you updated the default $pathsPath = realpath(FCPATH . '../app/Config/Paths.php'); to match the current directory structure?


Yes, I did otherwise it will not work

This is my pathsPath:

$pathsPath = realpath(FCPATH . 'app/Config/Paths.php');


RE: problem slash at the end of url - sammyskills - 12-11-2020

Okay.

I think the problem you're facing is related to the location of the index.php and .htaccess. From the docs, those files should be in your public folder.

I can't really say what you want to achieve by having those files outside of the public folder, maybe you can shed some light so I can understand better.


RE: problem slash at the end of url - Halim - 12-11-2020

(12-11-2020, 11:48 AM)sammyskills Wrote: Okay.

I think the problem you're facing is related to the location of the index.php and .htaccess. From the docs, those files should be in your public folder.

I can't really say what you want to achieve by having those files outside of the public folder, maybe you can shed some light so I can understand better.

Thank you for you reply,
I put the files outside of public because my goal is to host the application in a shared hosting, so I want to remove public folder from my url, and this is what most people suggest to do if you want to host the app in a shared hosting

I just tried it using the public folder and it has the same behavior!!


RE: problem slash at the end of url - InsiteFX - 12-11-2020

You need to edit the Paths.php file and give it the correct path to system and app folders.