PapT
PapT

Reputation: 623

How do I access Codeigniter 4 base url on live server?

I uploaded Codeigniter 4 to a shared hosting in a subdirectory. I can access the installation (the default controller) if I go to http://example.com/ci4/public but how can I access the default controller if I want to use http://example.com/ci4/

I already added http://example.com/ci4/ in App.php as baseurl. But currenty I'm getting a page not found error.

Upvotes: 1

Views: 3899

Answers (1)

Chibueze Agwu
Chibueze Agwu

Reputation: 990

Try this okay. I hope it will work

I discovered that when I try to point all my url to public/index.php in my project it return error 404 based on it can't find my controller after rewriting my .htaccess to point to public/index.php in my project root directory.

This is how I solved my problem =>
I move the index.php and the default .htaccess from public directory to my project root directory then I edit the index.php to locate my app directory
E.g
index.php Default find this line

// This is the line that might need to be changed, depending on your folder structure.
$pathsPath = FCPATH . '../app/Config/Paths.php';


Change it to

// This is the line that might need to be changed, depending on your folder structure.
$pathsPath = FCPATH . './app/Config/Paths.php';


I hope this work for you

Upvotes: 3

Related Questions