【问题标题】:How to redirect to public in laravel如何在laravel中重定向到公共
【发布时间】:2021-01-15 05:54:46
【问题描述】:

我将我的 laravel 项目从 localhost 上传到服务器,但要访问该应用程序,我的 url 是 http://myhostexample.com/public/ 我希望它是 http://myhostexample.com 我已经修改了 public/.htaccess,它是:

<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} !^public
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

【问题讨论】:

  • 站点的 docroot/webroot 应该指向公共文件夹

标签: laravel .htaccess redirect server localhost


【解决方案1】:

在 .htaccess 中你不应该改变任何东西;

您需要按照以下步骤部署 laravel 项目:

  1. 复制你的laravel项目中public文件夹的文件和文件夹,粘贴到public_html上

  2. 现在打开 public_html 并打开以编辑 index.php 文件

  3. 现在将 index.php 中的自动加载和引导路径更改为这些文件所在的位置

  4. 现在检查您的域

【讨论】:

  • 非常感谢! :)
猜你喜欢
  • 2015-07-01
  • 2017-09-18
  • 2019-06-27
  • 1970-01-01
  • 2018-10-19
  • 2021-03-30
  • 1970-01-01
  • 1970-01-01
  • 2013-09-02
相关资源
最近更新 更多