Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
716 views
in Technique[技术] by (71.8m points)

.htaccess - How do you redirect all request to public/ folder in laravel 5

I have a classic Larevel 5 project structure and I need to redirect all requests to public/.

I am on a classic hosting environment so public/ is a subfolder of my document root.

I shall imagine it can be done via .htaccess but I still need to figure out how. Anyone can help?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There are two solutions:

1. Using .htaccess with mod_rewrite

RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]

2. You can add a index.php file containing the following code and put it under your root Laravel folder (public_html folder).

<?php
header('Location: public/');

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...