【问题标题】:laravel 4 on shared hosting: PAGE NOT FOUND共享主机上的 laravel 4:未找到页面
【发布时间】:2014-11-30 15:30:48
【问题描述】:

由于客户端问题,我必须将 laravel 4 应用程序放在共享托管服务上。但我在 [laravelio] 遵循了这个过程,其中包括。

Place the files of the laravel public folder i.e. css, img, js etc; into public_html folder (don't dump public folder instead dump the files and folders in it).

Put all the remaining folders & files into another folder, say 'laravelcore' and place the laravelcore folder in the root (/home5/username/)

Open index.php in the public_html folder and replace the following lines as mentioned

require DIR.'/../bootstrap/autoload.php';

require __DIR__.'/../laravelcore/bootstrap/autoload.php';

$app = require_once DIR.'/../bootstrap/start.php';

$app = require_once __DIR__.'/../laravelcore/bootstrap/start.php';

Open paths.php file in laravelcore/bootstrap and replace the following line

'public' => DIR.'/../public',

'public' => __DIR__.'/../../public_html',

这应该可以工作,但是当我访问 url 时,我得到了这个:在这个服务器上找不到请求的 URL /login。请问可能是什么问题,因为我没有得到它。可能是关于配置 .htacces文件。

如有任何帮助,将不胜感激。谢谢 网址是:benin1897.com

我刚刚发现 public_html 文件夹中没有 .htaccess 文件。这可能是问题...

这是我的文件树

(/home/benincom) 等等 日志 邮件 oysg 应用程序 引导程序 小贩 公共ftp public_html css js 错误日志 自述文件 包.json 机器人.txt 时间

现在我登录了,但是 LARAVEL 抛出了错误

/ / |------------------------- -------------------------------------- |注册自动装载机|--------------------------------------------- ------------------------------ | | Composer 提供了一个方便的、自动生成的类加载器|对于我们的应用程序。我们只需要利用它!我们需要它 |把脚本放到这里让大家不用担心了| “手动”加载我们的任何类。放松的感觉很棒。 | / 需要 DIR.'/../oysg/bootstrap/autoload.php'; / |-------------------------------------------------------- ------------------------------ |打开灯|--------------------------------- ------------------------------ | |我们需要照亮 PHP 开发,所以让我们开灯吧。 |这会引导框架并准备好使用,然后它 |将加载此应用程序,以便我们可以运行它并发送 |响应返回浏览器并取悦这些用户。 | / $app = require_once DIR.'/../oysg/bootstrap/start.php'; / |-------------------------------------------------------- ------------------------------ |运行应用程序|---------------------------------- ---------------------------------------- | |一旦我们有了应用程序,我们就可以简单地调用 run 方法,|它将执行请求并将响应发送回 |客户的浏览器让他们享受创意|以及我们为他们准备的精彩应用程序。 | */ $app->run();

【问题讨论】:

  • 您能否以treeview 向我们展示您目前拥有的所有内容? (不是文档怎么说,而是你现在如何拥有它)。也许是编辑过的文件的转储(只是为了验证没有任何拼写错误)
  • 看起来你修好了? (如果我查看您的网站,我会看到一个不错的登录页面)

标签: laravel shared host


【解决方案1】:

您的/app/routes.php 中是否有这样的登录路径?

Route::get('/login', 'LoginController@login');

或者如果你不使用控制器(这不是一个好主意,但用于快速/肮脏的测试......)

Route::get('/login', function(){
    echo "Now we're going to login on this awesome website!!!";
});

更多关于Laravel Routes

编辑 1

控制器文件(/app/controllers/LoginController.php):

<?php

class LoginController extends BaseController {

    public function login() {
        echo "Now we are going to login in this awesome website!!!";
        // return View::make('pages/overig/login');
    }

}

您说您的公用文件夹中没有 .htaccess 文件。应该有一个。 创建文件并插入此内容并重试:

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

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

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

【讨论】:

  • 刚刚添加了这个:Route::get('/help', function(){ echo "现在我们要登录这个很棒的网站!!!"; });在我的控制器中,但仍然存在同样的问题
  • @AlofeOluwafemi,不要在你的控制器中添加它。将其添加到 /app/routes.php 文件中。我将添加控制器代码
  • 它是在我的路由中添加的,而不是我的控制器。我的错误是说控制器而不是路由。像这样 Route::post('/login',['as' => 'login' , '使用' => 'OYSGController@TryLogin']);
  • @AlofeOluwafemi,Route::post 将在您 POSTform 时使用。如果您只是导航到一个 URL,则需要使用 Route::get。有关Laravel Routing的更多信息
  • 我知道你 @Mathlight.am 只是想向你展示我了解如何制作路由和控制器。至少我的应用程序在本地运行得很好。
【解决方案2】:

听起来 .htaccess 文件配置不正确,因此您没有得到“漂亮的 URL”。尝试将示例文件从此处复制到您的 .htaccess http://laravel.com/docs/4.2/installation#pretty-urls

与此同时,您应该能够通过添加 index.php 来访问您的应用程序。例如 /login 不适合你,但如果你尝试 /index.php/login 它会工作

【讨论】:

  • 是啊坦克 /index.php/login 工作.. 仍然在 .htaccess 虽然
猜你喜欢
  • 2018-09-04
  • 1970-01-01
  • 1970-01-01
  • 2016-12-10
  • 2020-01-16
  • 1970-01-01
  • 2019-10-25
  • 2018-06-21
  • 1970-01-01
相关资源
最近更新 更多