@jlrdw if you want to point your server to the public directory of your laravel project, you can just set the root directory like this inside the server
server {
root /var/www/your-laravel-project/public;
// your other configurations...
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I use Apache, but want to try nginx.
To avoid having to do a VH every time I install a new WAMP, I have this htaccess in root to point to public as document root:
RewriteEngine On
RewriteRule ^(.*)$ public/
RewriteRule ^ server.php
Of course in public the "out of box" htaccess is there:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteBase /laravel842/ // only modified line
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# RewriteRule ^(.*)$ public/ [L]
</IfModule>
What is the equivalent in nginx to "direct" to public as document root?
Yes it's Linux only but the part about the virtual host setting are still valid. You need to change some paths other than that you should be good.
Couldn't find a good one for windows though.
Please or to participate in this conversation.