CodeIgniter Forums
No web server configuration - 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: No web server configuration (/showthread.php?tid=92964)



No web server configuration - Franky 5831 - 05-27-2025

Hello, I was wondering why there were no webserver configs,
a simple .htaccess config for apache would be really usefull.


RE: No web server configuration - michalsn - 05-27-2025

There is an .htaccess file: https://github.com/codeigniter4/CodeIgniter4/blob/develop/public/.htaccess

Also, there is a whole section in the user guide dedicated to .htaccesshttps://codeigniter.com/user_guide/installation/running.html#adding-htaccess


RE: No web server configuration - Franky 5831 - 05-27-2025

Sorry, I was talking about the one in the root of the project, when you create a new codeigniter4 project there is no .htaccess in the root.
Every time I create a new project it replies with a 403 and I need to create that config file.

Reading the guide (that I totally missed) I see that the codeigniter team thinks that "It is not recommended that you place the project folder in the document root", may I ask why that is?
Thanks.


RE: No web server configuration - captain-sensible - 05-27-2025

quote : Sorry, I was talking about the one in the root of the project, when you create a new codeigniter4 project there is no .htaccess in the root.

a .htaccess file at root of CI4 web project its not needed to work with Apache in my experience . On linux the only things i look at are defining url to serve web app in /etc/hosts , correct permission for directories and files and use a virtualhost file ,which among other things defines that the place for apache to listen to http requests is the public directory


RE: No web server configuration - michalsn - 05-27-2025

(05-27-2025, 01:29 PM)Franky 5831 Wrote: I see that the codeigniter team thinks that "It is not recommended that you place the project folder in the document root", may I ask why that is?

To protect sensitive files. Only the public/ folder should be web-accessible. If .htaccess or server settings are misconfigured, core files (app, system, writable) could be exposed, creating security risks.


RE: No web server configuration - Franky 5831 - 05-27-2025

(05-27-2025, 01:54 PM)captain-sensible Wrote: quote : Sorry, I was talking about the one in the root of the project, when you create a new codeigniter4 project there is no .htaccess in the root.

a .htaccess file at root of CI4  web project its not needed to work with Apache in my experience . On linux  the only  things i look at are  defining  url to serve web app  in    /etc/hosts  , correct permission for directories and files and  use a    virtualhost  file  ,which among other things defines that the  place for apache to listen to http requests is the public directory

Apache's default config doesn't do that, you have to manually edit it, that can be misconfigured too and in most projects it's not being tracked by git, on top of that if you need to deploy the same project among multiple servers (dev, testing, prod, prod-backup in some cases) you'll need to configure all those different apache configs, giving you more opportunities to misconfigure it.