How to change the root directory?

In development process, I am using Xampp to build my project.

In that, I configure the root directory in the httpd.conf like following:
DocumentRoot “C:/xampp/htdocs/aeee/public”
<Directory “C:/xampp/htdocs/aeee/public”>

Actually, the index.php is located in the aeee/public (aeee is the project folder).
Can I change the root directory like in the xampp config above ?

Thank you guys in advance.

Changing your root directory isn’t supported, but you can use RewriteRules in a .htaccess file within your htdocs folder to redirect requests to the public directory. Here’s an example from StackOverflow:

10 Likes

Thanks for your answer. But it still not working.

For example, the project folder structure look like this:
aeee/
|-- controllers
|-- models
|-- views
|-- public/
| |-- css
| |-- fonts
| |-- images
| |-- js
| -- index.php |-- .env |-- composer.json – …

To run this on local, I am go to the public folder and run the command: php -S localhost:8080

Can I achieve something like this on this hosting platform. I have searching solution for a while. But I am not found anyone face this problem.

Sorry for my mistake. The project folder structure may look like this:
image

A nice and simple snippets that just rewrites everything to the public folder is the one I shared here:

Could you please try this one instead of the rewrite snippet you are using now?

6 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.