如何重定向到laravel上的公用文件夹

时间:2022-06-12 00:32:51

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

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

3 个解决方案

#1


22  

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/$1 [L]

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

把它放到你的public_html /或www /文件夹中,这是example.com/的根目录

#2


6  

rename /server.php to index.php

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

#3


0  

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");

#1


22  

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/$1 [L]

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

把它放到你的public_html /或www /文件夹中,这是example.com/的根目录

#2


6  

rename /server.php to index.php

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

#3


0  

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");