简体   繁体   中英

route issue when I host my laravel 5 website on a Shared hosting

hello everyone I'm new on laravel. I build my website which is perfectly working on the development machine but when I put it on my shared hosting it is just one route which is working ("/"). all the order routes are not working.

web.php (the first route is working)

<?php

Route::get('/', function () {
return view('index');}); 

Route::group(['prefix' => '{lang}'], function(){
Route::get('index', function(){
    return view('index');
});

Route::get('t', function(){
    return view('construction');
});

Route::get('post', function(){
    return view('post');
});

Route::get('posts', 'postController@index');
});

my .htacces

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

RewriteEngine On

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

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

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

index.blade.php is in the folder views of ressources and the lang files exist. if anyone can help me it will be great

Here what you can do..

Step 1: Go to public folder, copy .htaccess file to root ( / ) directory

Step 2: Rename server.php to index.php in root folder

Step 3: Open vendor/laravel/framework/src/Illuminate/Foundation/helper.php

Step 4: find code block

function asset($path, $secure = null)
{
   return app('url')->asset($path, $secure);
}

Replace it with

function asset($path, $secure = null)
{
   return app('url')->asset('public/'.$path, $secure);
}

You are good to go.. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM