Laravel将项目重定向到"projectURL/public/public". [英] Laravel redirecting project to "projectURL/public/public"

查看:58
本文介绍了Laravel将项目重定向到"projectURL/public/public".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,这是我的laravel和PHP版本:Laravel Framework 7.17.2PHP 7.3.19(cli)

first of all this are my laravel and PHP versions: Laravel Framework 7.17.2 PHP 7.3.19 (cli)

我的laravel项目遇到了一个奇怪的问题:

I am having a wierd problem with my laravel project:

我的虚拟主机文件中有:

<VirtualHost *:80>
    ServerName www.name.test
    DocumentRoot "C:\web\name\name\backend\public"
</VirtualHost>

在主机文件中:

127.0.0.1 www.name.test

127.0.0.1 www.name.test

在尝试通过键入以下内容来访问项目时: http://www.name.test 它将我重定向到URL http://www.name.test/public/public

when trying to acces the project by typing: http://www.name.test it redirects me to the url http://www.name.test/public/public

我的根文件夹和公用文件夹中都有.htaccess,其内容如下:

I have .htaccess in my root folder and in the public folder with the following :

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

我不知道为什么会开始发生这种情况,以前它可以正常工作,但是由于在每台计算机上都发生了意外,我猜我在项目上意外更改了它,所以它看起来不像是php配置问题.

I dont know why this started to happen, previously it was working fine but sth I gues was changed accidentally on the project since it happens in everycomputer, so it does not look like a php configuration problem.

希望有人可以给这个问题一些提示.

hope someone can give some tip about the issue.

推荐答案

有2种方法可以解决此问题:

There are 2 ways to fix this issue:

第1步:

只需将您的 server.php 重命名为项目根目录中存在的 index.php 文件.

Just rename your server.php to index.php file present in your project root directory.

第2步:

复制项目根目录的公用文件夹中存在的 index.php 并将其粘贴到根目录中.确保之前没有其他 index.php .

Copy index.php present inside public folder of your project root directory and paste it inside the root directory. Make sure there is no other index.php present before.

然后替换这两行:

require __DIR__.'/../vendor/autoload.php';
require_once __DIR__.'/../bootstrap/app.php';

使用

require __DIR__.'/vendor/autoload.php';
require_once __DIR__.'/bootstrap/app.php';

希望两种方法中的任何一种都可以帮助!

Hope either of the 2 ways helps!!

这篇关于Laravel将项目重定向到"projectURL/public/public".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆