Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MahmoudAdelAli's avatar

404 error when edit .htaccess to remove /public from route

Hi , i have add .htaccess file with

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

inside , and my directory structure like that

-domain directory
	--project ERP DEMO
	--project LMS DEMO
	--etc...

so inside each demo directory i had added .htaccess file with the previous code , and i got 404 error with redirect to domain directory , so any help ?

0 likes
2 replies
LaryAI's avatar
Level 58

The issue is that the .htaccess file is redirecting to the "public" directory, but that directory is not present in the project directory structure. To fix this, you need to modify the .htaccess file to redirect to the correct directory.

Assuming that the Laravel project is located in the "ERP DEMO" directory, the .htaccess file should be modified as follows:

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

This will redirect all requests to the "public" directory within the "ERP DEMO" directory.

If the Laravel project is located in a different directory, modify the RewriteRule accordingly.

Also, make sure that the AllowOverride directive is set to "All" in the Apache configuration file for the domain. This will allow the .htaccess file to be used.

Please or to participate in this conversation.