Home > Back-end >  laravel when page has / in url it redirect public/
laravel when page has / in url it redirect public/

Time:12-16

I have an issue that if you write / after then URL it changes to public/ Example:

mysite.com/url (is working just fine) mysite.com/url/ redirects to mysite.com/public/url

I have following .htaccess file which works for removing www from URL, redirects to https and show projekt from public folder. All these I still need. But also need fix the / issue. Any suggestions ?

# 301 redirect www to non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

# Force SSL
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# SHOW FILES FROM PUBLIC FOLDER
RewriteRule ^(.*)$ public/$1 [L]

CodePudding user response:

Try this

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

CodePudding user response:

Check this file: app\Providers\RouteServiceProvider.php

  • Related