请,我正在尝试在共享主机上托管Laravel 5。
当我访问www.example.com/my_app_name时,页面正确加载。但是,子文件夹返回404错误。例如www.example.com/my_app_name/any_sub_folder或www.example.com/my_app_name/auth/login都返回404错误。
shared_hosting_root
|--other_folders (not accessible via web domain)
|--applications (not accessible via web domain)
|--my_app_name
|--app
|--GoPublic.php <--I created this
|--bootstrap
|--config
|--database
|--public <--copied content to public_html
|--assets
|--index.php
|--resources
|--storage
|--tests
|--vendor
|--public_html
|--my_app_name
|--assets
|--index.php <-- I pointed here
我创建了一个新文件:shared\u hosting\u root\applications\my\u app\u name\app\GoPublic。php
<?php namespace App;
class GoPublic extends \Illuminate\Foundation\Application
{
/**
* Get the path to the public / web directory.
*
* @return string
*/
public function publicPath()
{
return $this->basePath.DIRECTORY_SEPARATOR.'../../public_html/my_app_name';
}
}
我编辑引导\app.php这样:
<?php
/* -- remove/comment this original code
$app = new Illuminate\Foundation\Application(
realpath(__DIR__.'/../')
);
-- until here */
/* -- add this new code -- */
$app = new App\GoPublic(
realpath(__DIR__.'/../')
);
我编辑公共\index.php这样:我改变了这个:
require __DIR__.'/../bootstrap/autoload.php';
到
require __DIR__.'/../../applications/my_app_name/bootstrap/autoload.php';
也改变了这一点:
$app = require_once __DIR__.'/../bootstrap/app.php';
到
$app = require_once __DIR__.'/../../applications/my_app_name/bootstrap/app.php';
然后,我将applications\my\u app\u name\public中的内容复制到public\u html\my\u app\u name中。
我遵循了本教程中强调的步骤:http://blog.kongnir.com/2015/09/25/setting-up-laravel-5-on-shared-hosting-server/
问题又来了:
我可以访问www.example。com/my_app_name。
但是我得到一个404错误www.example.com/my_app_name/any_sub_folder甚至登录重定向www.example.com/myapp_name/auth/login
我做错了什么?请帮忙。非常感谢。
更新www.example.com/my_app_name/sub_folder返回500内部服务器错误我的. htaccess文件在public_html目录:
# Do not change this line.
RewriteEngine on
# Change example.com to your domain name
# RewriteCond %{HTTP_HOST} ^(www.)?schoolsmart.com.ng$
# Change your_app_name to the subfolder name
# RewriteCond %{REQUEST_URI} !^/wbs/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change your_app_name to the subfolder name
# Change example.com to your domain name
# RewriteRule ^(.*)$ /wbs/$1
# RewriteCond %{HTTP_HOST} ^(www.)?schoolsmart.com.ng$
# RewriteRule ^(/)?$ wbs/index.php [L]
RewriteCond %{REQUEST_URI} !^wbs
RewriteRule ^(.*)$ wbs/$1 [L]
对于我来说,将供应商目录下的bootstrap、storage和yajra文件夹修改为775,正如官方laravel文档中所建议的那样,成功了。