首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Laravel部署共享托管子域

Laravel部署共享托管子域
EN

Stack Overflow用户
提问于 2021-04-02 01:51:51
回答 1查看 1.1K关注 0票数 1

嗨,我花了几个小时让我的网站在共享主机上工作,但什么也没发生(在本地没什么问题),我搜索了几个主题,并遵循了教程,但无法解决无法加载引导程序和livewire组件的问题。

我遵循了将公用文件夹复制到子域根目录的经典步骤,其他文件位于子域路径中的单独文件夹上,比如Laravel文件夹,我更改了public/index.php和im,得到了类似于的内容

如您所见,livewire和引导程序不起作用。

此外,我试图让文件夹作为原始和我的路径到公共,结果是像和一切的工作!

不工作的索引路径css和livewire:

代码语言:javascript
复制
<?php

use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Check If Application Is Under Maintenance
|--------------------------------------------------------------------------
|
| If the application is maintenance / demo mode via the "down" command we
| will require this file so that any prerendered template can be shown
| instead of starting the framework, which could cause an exception.
|
*/

if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {
    require __DIR__.'/../storage/framework/maintenance.php';
}

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| this application. We just need to utilize it! We'll simply require it
| into the script here so we don't need to manually load our classes.
|
*/

require __DIR__.'/laravel/vendor/autoload.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request using
| the application's HTTP kernel. Then, we will send the response back
| to this client's browser, allowing them to enjoy our application.
|
*/

$app = require_once __DIR__.'/laravel/bootstrap/app.php';

$kernel = $app->make(Kernel::class);

$response = tap($kernel->handle(
    $request = Request::capture()
))->send();

$kernel->terminate($request, $response);

我知道我没有把/../因为我得到错误不识别路径如果我放置,可能是因为是子域,而且没有public_html文件夹。是什么原因造成了这个问题?引导的路径是正确的。

Web.config:

代码语言:javascript
复制
<!--
    Rewrites requires Microsoft URL Rewrite Module for IIS
    Download: https://www.iis.net/downloads/microsoft/url-rewrite
    Debug Help: https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules
-->
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Imported Rule 1" stopProcessing="true">
          <match url="^(.*)/$" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Redirect" redirectType="Permanent" url="/{R:1}" />
        </rule>
        <rule name="Imported Rule 2" stopProcessing="true">
          <match url="^" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

htaccess:

代码语言:javascript
复制
<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>
代码语言:javascript
复制
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-04-16 12:03:30

很晚了,但希望对未来的观众有用。

从我能读到的评论中你在使用Hostinger,

这里有个快速的工作,

在您的托管帐户>选择

托管帐户>域> SubDomains

输入子域名和

检查自定义文件夹中的子域。

输入您的项目的路径,然后是laravel的公共区域。

比如,

代码语言:javascript
复制
/home/u796769252/public_html/<subdomain>/public

瞧,

现在,您可以将您的laravel核心文件粘贴到服务区,并将公用文件夹文件粘贴到公用文件夹。

我编写了一个博客,其中我提到了如何在不编辑laravel核心文件的情况下将laravel应用程序发布到共享主机。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66913555

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档