Answer the question
In order to leave comments, you need to log in
How to make 301 redirect to public in htaccess in Laravel?
Good day.
There is a site on Laravel
When visiting the url https://site.ru/public/custom-slug and https://site.ru/custom-slug
the same page opens.
How can I write a 301 redirect in htaccess so that when I visit a url with public, it will be redirected to
a url without it.
Now htaccess is like this
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.site.ru$ [NC]
RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
<Files *.env>
Deny from all
</Files>
</IfModule>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question