如何重定向到 Laravel 上的公共文件夹

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29829559/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 11:25:48  来源:igfitidea点击:

How to redirect to public folder on laravel

.htaccessredirectlaraveldirectorypublic

提问by Andres Ruales

I have this structure:

我有这个结构:

My domain: www.example.com

我的域名:www.example.com

and this is my laravel's project folder: http://www.example.com/project

这是我的 Laravel 项目文件夹:http: //www.example.com/project

and I would like to redirect to http://www.example.com/project/public

我想重定向到http://www.example.com/project/public

I know this answer has been answered before but I try to implement it and not work for me.

我知道之前已经回答过这个答案,但我尝试实施它而不适合我。

Sorry for my english, I just speak spanish

对不起我的英语,我只会说西班牙语

回答by Germanaz0

For htaccess

对于 htaccess

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteCond %{REQUEST_URI} !project/public/
RewriteRule (.*) /project/public/ [L]

Put it into your public_html/ or www/ folder where is the root of example.com/

将其放入您的 public_html/ 或 www/ 文件夹中,该文件夹是 example.com/ 的根目录

回答by Basem Olimy

rename /server.php to index.php

将 /server.php 重命名为 index.php

回答by Erhnam

I created this php script and placed in the in the root of the laravel directory:

我创建了这个 php 脚本并将其放在 laravel 目录的根目录中:

    $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
    header("Location: " . $actual_link . "public/index.php");