What APP_URL value have you written in the .env file ?
How to remove /public/ from a Laravel 10
I want to remove the /public/ fragment from my Laravel 10 URLs.
I have tried several things regarding public.
1- I have changed the .htaccess. Yes it worked.
domain.com/public/contact : it is valid
domain.com/contact : it is valid
But i have another problem, google thinks i have duplicate pages.
2- Then, i have tried to another way, I changed the root of website as public.
Everything was worked.
But when i open the url domain.com/public i got error. Too many redirections. It automatically downloaded a file. it's name is public without extention.
At the end, i want to remove public segment from the url. When i enter the domain.com/public/contact, i should get 404 error. :tired_face:
Can you help me solve this problem , thank you in advance. .env
APP_URL=https:// domain.com
#public .htaccess
<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>
@argethink Ok ... no problem ... so first you should modify the APP_URL to set it with the right value.
Concerning the .htaccess file, here is the one I'm using (try to add the RewriteBase line).
<IfModule mod_rewrite.c>
RewriteBase /
<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>
Please or to participate in this conversation.