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

viktor3177's avatar

Folder /public/ Laravel in the link.

I can't figure out where the error is! I uploaded the site to the hosting, but when you go to the pages of the site (domen .com/page), the folder /public/.

It turns out such a link (domen .com/public/page).

Here is the file code (.htaccess) from the folder (public).

<IfModule mod_rewrite.c>
	<IfModule mod_negotiation.c>
		Options -MultiViews -Indexes
	</IfModule>

	RewriteEngine On

	# 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]
</IfModule>

And the file (.htaccess) from the root folder.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/ [L]
</IfModule>
0 likes
4 replies
jlrdw's avatar

First do not modify the htaccess in public, and in root, this one works to point to public:


RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^ [N]

RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/ 

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php

Only used if a virtual host can't be used.

You may want to look into using Nginx instead and follow:

https://laravel.com/docs/9.x/deployment#main-content

But you need to point to public as document root one way or the other, a virtual host is the preferred way.

viktor3177's avatar

@jlrdw

Did I understand correctly that the file (.htaccess) should not be in the folder (public)?

Please or to participate in this conversation.