Laravel 5共享托管问题

时间:2016-02-10 22:42:14

标签: laravel laravel-5 shared-hosting

拜托,我正在尝试在共享主机上托管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_hosting_root \ applications \ my_app_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';
 }
}

我像这样编辑了bootstrap \ 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__.'/../')
);

我像这样编辑了public \ 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_app_name \ public中的内容复制到public_html \ my_app_name。

我按照本教程中突出显示的步骤进行操作:http://blog.kongnir.com/2015/09/25/setting-up-laravel-5-on-shared-hosting-server/

问题再次出现:

我可以访问 www.example.com/my_app_name

但是我在 www.example.com/my_app_name/any_sub_folder 上获得 404错误,甚至是登录重定向 www.example.com/myapp_name/auth /登录

我做错了什么?请帮忙。 谢谢。

更新 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]

1 个答案:

答案 0 :(得分:0)

对于我来说,按照官方laravel文档的建议,将供应商目录下的bootstrap,storage和yajra文件夹修改为775,就可以了。

相关问题