I see that your project is located in the htdocs folder by default. In this case, without any modifications, you can access the public folder on port 80 using:
http://localhost/AppName/public/index.php
If the goal is to make your application secure locally and prevent direct access to files belonging to other projects (e.g., http://localhost/AppName/.env), then it is necessary to change the htdocs folder so that it points to your project's public folder. This is a huge security vulnerability, as the database password, for example, is stored in the .env file.
This way, you can access the public folder via http://localhost, and there will be no possibility to load content outside of the public folder. (Yes, in this case http://localhost/../.env will invalid request.)
Note: In my answer, I am not using the exact paths you provided, as I am trying to generalize the instructions. However, C:\path\to\laravelproject refers to your D:\xampp\htdocs\AppName directory.
Requirements
To host a website from your own machine on an internal network, you need a web server. XAMPP can be a great option for this, especially if you configure it to start automatically when Windows boots up.
- Set your
xampp.exe to start automatically on Windows startup.
- In XAMPP, configure it to automatically start the web server and MySQL when the app launches (so you don't have to start them manually).
After that, you just need to manipulate the default root directory of the localhost:80 web address started by XAMPP - which is set to .\xampp\htdocs by default -; so that it points to the Laravel's public folder.
Set public directory with XAMPP
Solution #1: Change XAMPP default htdocs folder path (recommended)
Find and open the C:\path\to\xampp\apache\conf\httpd.conf file.
Look for a line where the DocumentRoot is set to C:\path\to\xampp\htdocs. Change it to:
DocumentRoot C:\path\to\laravelproject\public
If you want to continue using PHPMyAdmin, you will need an additional alias as well.
Find and open the C:\path\to\xampp\apache\conf\extra\httpd-xampp.conf file.
Look or create a new line where the Alias /phpmyadmin is set to C:\path\to\xampp\htdocs\phpMyAdmin. If not exists create this new line:
Alias /phpmyadmin "C:\path\to\xampp\htdocs\phpMyAdmin"
After that should restart XAMPP webserver.
Solution #2: Copy project's public folder to htdocs
By default, it will host the C:\path\to\xampp\htdocs folder. You should place the contents of your Laravel project's public folder inside the C:\path\to\xampp\htdocs folder.
If you choose to copy, you will need to make edits in the copied index.php file. You will find some relative paths that look for files in a parent directory. These need to be rewritten to point to your Laravel project.
Solution #3: Create a symlink from htdocs to project's public
On Windows, creating a symlink could also work, like C:\path\to\xampp\htdocs --> C:\path\to\laravelproject\public).
# By default htdocs existed, remove it by rename
ren "C:\path\to\xampp\htdocs" "C:\path\to\xampp\htdocs.bak"
# Run as administrator from cmd
mklink /D "C:\path\to\xampp\htdocs" "C:\path\to\laravelproject\public"
Note: I would not apply the descriptions of Solution #2 and #3 directly to the htdocs folder, but rather to the .\htdocs\myproject folder. In this case, however, the URL for your web application would not be http://localhost, but rather http://localhost/myproject.
Call project from browser
After this, you can load your Laravel project in the browser via the http://localhost port. (If there is no port specified, it refers to port 80, meaning by default, XAMPP is accessible via localhost:80.)
In your Laravel project's .env file, change the default paths from http://localhost:8000 to http://localhost. If you're not using this machine directly, I recommend using your computer's internal network IP address instead of localhost: http://192.168.0.100.
Note: If the machine from which you want to access the locally hosted website is not on the same network as the "server" machine, you can set up a virtual LAN network, for example, using RadminVPN or similar services. But in this case, you would need to set your VPN address in the .env file.
Installation as production
If you do not intend to develop or modify this application, it is advisable to set it up as a "production" version.
php artisan servecommand opens a direct port to your Laravel project so that it can be easily accessed. I'm not entirely sure what you're trying to automate. For production code, you should point your domain to the/publicdirectory. This way,example.com, which points to thepublicfolder, will route all incoming requests to/public/index.phpdue to the.htaccessfile in that folder.php -S $host:$port -t public/