Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add note for index.php change #8549

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions user_guide_src/source/installation/upgrade_4xx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ Namespaces
Application Structure
=====================

.. important::
**index.php** is no longer in the root of the project! It has been moved inside
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The internet is full of these types of videos, I am shocked every time I see them.
It seems that because shared hosts are used, it is practically not possible to set Document Root
from cPanel or etc . So they have to do this.
It is better to link these explanations together with the explanations given in Shared Hosts.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a link to a forum article. It seems the way in the article is a bit bothersome, but a better way for shared hosts that cannot set the document root.
This blog article also does the same way.
https://medium.com/@ayushbulbule/how-to-deploy-your-codeigniter-4-website-to-hostinger-cpanel-f66e84dfc45b

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I upload the project in public_html.
Then I create a file public_html/.htaccess in the root of the project and fill it with the following code.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

<FilesMatch "^\.">
    Require all denied
    Satisfy All
</FilesMatch>

The project is now available via https://mydomain.com/ instead of https://mydomain.com/public/.

Screenshot 2024-02-16 074504

Exactly the same as in Adding .htaccess.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That method is fine as long as Apache's .htaccess works fine.

However, it places files in the public area that do not need to be made public, and then adds rules to prevent access to certain files.

If we follow security principles, we should only place files in the public area that are likely to be accessed from the beginning.

This is because if there is a bug in Apache or if you accidentally modify .htaccess, files that should not be publicly accessible could be accessed.

That said, the method described in the forum, where the folder structure changes between the development (repository) folder structure and the production server folder structure, is also a bit complicated to deploy.

It is best if you can specify the document root as public in the server configuration.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sent another PR #8554 to add docs about Shared Hosting Services.

the **public** folder, for better security and separation of components.

This means that you should configure your web server to "point" to your project's
**public** folder, and not to the project root.

If you would use Shared Hosting, see :ref:`deployment-to-shared-hosting-services`.

- The **application** folder is renamed as **app** and the framework still has **system** folders,
with the same interpretation as before.
- The framework now provides for a **public** folder, intended as the document root for your app.
Expand Down