Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mahedi2014/980eb320b538593a4740f5b589468660 to your computer and use it in GitHub Desktop.
Save mahedi2014/980eb320b538593a4740f5b589468660 to your computer and use it in GitHub Desktop.
How to host laravel in a subfolder on shared host
Let project name is "my_project". So all project files is contain this folder "my_project" as a root directory.
##Process
1. Cut the .htaccess file from "public" folder (my_project\public\.htaccess) and past it into root directory (my_project\)
2. Rename the server.php file (my_project\server.php) in root directory to index.php (my_project\index.php)
3. Open helper.php file (my_project\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php)
Replace the line in laravel 6.0 at line 148 of function "asset"
return app('url')->asset($path, $secure); to return app('url')->asset('/public/'.$path, $secure);
##Previous code:
<code>
if (! function_exists('asset')) {
/**
* Generate an asset path for the application.
*
* @param string $path
* @param bool|null $secure
* @return string
*/
function asset($path, $secure = null)
{
return app('url')->asset($path, $secure);
}
}
</code>
##New code
<code>
if (! function_exists('asset')) {
/**
* Generate an asset path for the application.
*
* @param string $path
* @param bool|null $secure
* @return string
*/
function asset($path, $secure = null)
{
return app('url')->asset('/public/'.$path, $secure);
}
}
</code>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment