DEV Community

Discussion on: Setup An .Htaccess File For Redirecting To Laravel’s Public Folder

Collapse
 
saronlujan profile image
Saron Lujan

Hi! In your opinion, it is more advantageous to change the document_root or use htaccess. Is there a significant difference between the two? Because I can change the document_root, but lately I'm using .htacess because it's easier and faster and I can configure it in the deploy directly.

Thread Thread
 
cremirdevio profile image
Joseph • Edited

Not just an advantage. It is the right approach.

An excerpt from Laravel Doc:

Please ensure, like the configuration below, your web server directs all requests to your application's public/index.php file. You should never attempt to move the index.php file to your project's root, as serving the application from the project root will expose many sensitive configuration files to the public Internet

laravel.com/docs/9.x/deployment#nginx

To the main question: there's no significant difference, .htaccess is a normal configuration for your webserver, so its fine to do it there too.