![]() |
How to remove public/index.php from 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: How to remove public/index.php from the URL (/showthread.php?tid=78240) |
How to remove public/index.php from the URL - t_5810 - 12-19-2020 Hello. I have uploaded my demo application on production server, which uses cpanel, in a subdomain (if that is important) If I visit my url http://ea3.mydomain.net.be I get 403 Forbidden error If I add public/index.php on the end of my URL: http://ea3.mydomain.net.be/public/index.php , I can see the page normally My .env settings: CI_ENVIRONMENT = production app.baseURL = 'http://ea3.mydomain.net.be' My app/Config/App.php is untouched, it is the same as I downloaded it from CodeIgniter site. I use the .env file as suggested on this forum. Now, about my folder structure. As far as I can understand the CI 4 documentation only the public folder should be in the pubic_html folder, and everything else should be outside of it. But I have no such options: I have my folder: ea3.mydomain.net.be and no other subfolders, so all folders from the default CI Installation are in that folder. My host use cpanel. On the end: I make my homework. I searched here, and I found no useful advice on this topic. I make the research on Internet, and I found zillion copies of how to remove public and index.php from the URL in Codeigniter 4 and they are all SAME. Same code everywhere, and I highly doubt that those people have an idea what CodeIngiter is. What I think is that they are all after clicks, they find that someone write an article on that topic, they see no competitions, and they are trying to get clicks, since the code is SAME on all those pages. So this forum in the only place where I am sure that I am asking the people who know what they are talking about. So, I am relying on your expertise. Cheers and happy holidays to all members of this community. P.S. For some reason I was unable to remove the links. The remove link has been grayed I was unable to use it. RE: How to remove public/index.php from the URL - InsiteFX - 12-19-2020 If index.php is suppose to be in public_html then you need to rename the public folder public_html If you do that you also will need to edit the spark file and change the public to public_html. There maybe other setting that also need to be changed, I have all my apps under public_html but no sub-folders. RE: How to remove public/index.php from the URL - t_5810 - 12-21-2020 Thanks for your reply I have no public_html folder at all. I have one folder (named as my domain) and that is the root folder. And inside I have all my files and folders as they has been downloaded from CodeIgniter. --mydomainname -.well-known -app -cgi-bin -public -system -writable .env .robots.txt And I am still getting that 403 Forbidden error. So, how should I change my folder structure, or my .env file to get rid of the error? RE: How to remove public/index.php from the URL - includebeer - 12-21-2020 If your host gives you something like /home/username/domain.com/, put the content of the public folder in /home/username/domain.com/ and everything else in /home/username/ It seems like everybody is confused by the new way CI4 deal with the concept of public and private folders. The content of "public" goes in your public folder, whatever its name is, and everything else goes one level up, so it's not publicly accessible. RE: How to remove public/index.php from the URL - t_5810 - 12-22-2020 (12-21-2020, 06:19 AM)includebeer Wrote: If your host gives you something like /home/username/domain.com/, put the content of the public folder in /home/username/domain.com/ and everything else in /home/username/ I appreciate the fact that you find time to answer my question. However, no I have no such luxury on this host. What I have is one folder: mydomain.be And I have to find a solution that will work on all hosts, since I use CodeIgniter in all my projects, so I need to find a way around this obstacle, which will not compromise the security of the website - app. Needles to say, exactly the fact that that all files should be outside of the root folder significantly increases the security, but how to find a solution that will work on all hosts is the question of 1 million $... Hopefully some of the community will find the right answer. Once again, thanks for your answer... RE: How to remove public/index.php from the URL - InsiteFX - 12-22-2020 In that case I would start looking for a new host. I have my hosting with. WebHostingBuzz I have been with them for over 10 years now because they have one of the best support around. They will even make changes for you to make sure things work the way you want them to. RE: How to remove public/index.php from the URL - includebeer - 12-22-2020 (12-22-2020, 07:54 AM)t_5810 Wrote: And I have to find a solution that will work on all hosts, since I use CodeIgniter in all my projects, so I need to find a way around this obstacle, which will not compromise the security of the website - app. It's better to have most of the code outside the root folder, but if your host gives you no other choice, I'm sure you can make it work with everything in your public folder. Before CI4, a lot of people didn't bothered to move the application and system folders outside the root. You'll have to edit index.php so it can find your app folder: PHP Code: <?php |