1

Hi i spend few hours to make my website work on shared host but nothing happened(locally its OK), Searched few topics and followed tutorials but cant fix the problem that cant load bootstrap and livewire components.

I followed the classic step that copy the public folder to the root of my subdomain and the other files are on separate folder inside the subdomain path like Laravel folder I change the public/index.php and im getting something like this

as you can see the livewire and the bootstrap doesn't work.

Also i tried to let the folders as original and i path to public and the result is like this and everything's work !

The index path that doesnt work css and livewire:

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

I know that i didnt put /../ because i get error doesn't recognize the path if i put that, maybe because is subdomain, and doesn't have public_html folder. What cause that problem ? the path of bootstrap is correct..

Web.config :

<!--
    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 :

<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>
7
  • Why are you using a Shared Host ? Do you even have SSH access ? The importan thing should be that Apache or Nginx document root is LARAVEL_ROOT/public and that's it, then everything should be in the root like app, bootstrap, storage, etc folders... Commented Apr 2, 2021 at 2:05
  • Because are vfm option instead of expensive vps with limited space, I have ssh access but I don't now what can I do to fix them Commented Apr 2, 2021 at 2:15
  • Are you using Apache or Nginx ? Could you share in your post the config file for your site ? Commented Apr 2, 2021 at 3:18
  • @matiaslauriti Im on Hostinger shared host and im using Apache, i uploaded htaccess and web.config on post Commented Apr 2, 2021 at 10:51
  • I have no idea what hostinger has. If you are using Apache, can you share the virtual host that is on /etc/apache2/sites-available Commented Apr 2, 2021 at 20:48

1 Answer 1

7

Its late, but hopefully useful for future viewers

From the comments I could read you are using Hostinger,

Here is a quick work around,

In your hosting account > select

Hosting Account > Domains > SubDomains

Enter the sub domain name and

check the custom folder for subdomain

Enter the path of your project followed by the public dir of laravel

for eg,

/home/u796769252/public_html/<subdomain>/public

Voila,

you can now paste your laravel core files to suddomain and public folder files to the public folder.

I wrote a blog where I mentioned how to publish laravel application to shared hosting without editing the laravel core files.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes it worked, i faced again the same problem and i followed exact your instructions and finally Worked! Thank you very much

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.