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

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Feb 16, 2024

Description
I saw a YouTube video that a dev had moved index.php to the project root.
Also this description is on the README file, but not in the User Guide upgrading section.

aChecklist:

  • Securely signed commits
  • [] Component(s) with PHPDoc blocks, only if necessary or adds value
  • [] Unit testing, with >80% coverage
  • User guide updated
  • [] Conforms to style guide

@kenjis kenjis added the documentation Pull requests for documentation only label Feb 16, 2024
@@ -47,6 +47,13 @@ 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.

@kenjis kenjis marked this pull request as draft February 17, 2024 01:17
@kenjis kenjis marked this pull request as ready for review February 17, 2024 05:35
@kenjis kenjis marked this pull request as draft February 17, 2024 05:36
@kenjis kenjis force-pushed the docs-upgrade_4xx.rst branch from 025e978 to a9c17a9 Compare February 22, 2024 00:24
@kenjis kenjis marked this pull request as ready for review February 22, 2024 00:25
@kenjis
Copy link
Member Author

kenjis commented Feb 22, 2024

Updated the description to add a link to another page.

@kenjis kenjis merged commit 65c6a61 into codeigniter4:develop Feb 22, 2024
3 checks passed
@kenjis kenjis deleted the docs-upgrade_4xx.rst branch February 22, 2024 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Pull requests for documentation only
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants