This issue occurs because Laravel is designed to restrict direct access to files outside the public directory for security reasons. The documents and files that are meant to be accessed by the users should be placed in the public directory, typically found at the root directory of the project.
To access the Laravel website, you need to configure your web server to point to the public directory as the website’s document root. This can be done by creating a virtual host for the website or by modifying the server configuration.
If you are using Apache, you can modify the .htaccess file inside the public directory to enable pretty URLs. Add the following code to the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
This code will rewrite all requests to the public directory, allowing you to access your Laravel website without the need to append /public/ to the URL.
Make sure to clear the Laravel application cache after modifying the .htaccess file by running the following command in the terminal:
php artisan config:cache
This should fix the issue and allow you to access your Laravel website without adding /public/ to the URL.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-05-04 00:12:39 +0000
Seen: 10 times
Last updated: May 04 '23
How can a HTTP header be inserted in WordPress?
How can data be stored in a data attribute and utilized through Ajax?
How can an array be passed using typo3 flexform xml and itemsProcConfig?
Does JSON encode fail to retrieve data from the database?
Can the GS1 128 barcode decoder in PHP or Jquery be utilized?
How can Xdebug be used in conjunction with VSCode for Laravel on Sail and WSL2?
In PHP, what is the method for finding encrypted data using the "like" operator?
What is the method to pass a variable from PHP back to JavaScript?
Why do PHP variable variables display unexpected behavior when used with arrays?