Laravel 4在共享主机上的路由问题

时间:2014-06-14 20:51:42

标签: php .htaccess laravel laravel-4

我刚刚在GoDaddy共享托管上推出了一个Laravel 4驱动的网站,我遇到了一个问题 - 在成功登录后,网站尝试将我重定向到正确的页面,在邮件更改后,它将我重定向回到主页。

它向我显示this,一秒后它变为this并将我带回主页。

您可以访问the website并使用serban作为用户名并使用start1作为密码登录,亲自尝试使用此功能。

路线:

Route::post('/account/sign-in', array(
    'as' => 'account-sign-in-post',
    'uses' => 'AccountController@postSignIn'
    ));

Route::get('/account/sign-in', array(
    'as' => 'account-sign-in',
    'uses' => 'AccountController@getSignIn'
    ));

Route::get('/account/create-char', array(
    'as' => 'create-character',
    'uses' => 'AccountController@getCharCreate'
    ));

Controller AccountController

   public function getCharCreate() {
    return View::make('account.createchar');
}

public function postSignIn() {
    $validator = Validator::make(Input::all(),
        array(
            'username'      => 'required',
            'password'  => 'required'
            )
        );

    if($validator->fails()) {
                //Redirect to sign in page
        return Redirect::route('home')
        ->withErrors($validator)
        ->withInput();
    } else {
                //Attempt user sign in
        $remember = (Input::has('remember')) ? true : false;
        $auth = Auth::attempt(array(
            'username' => Input::get('username'),
            'password' => Input::get('password'),
            'active' => 1
            ), $remember);  


        if($auth) {
                    //Redirect to intended page

            Session::put('theuser', Input::get('username'));



            $resultchar = DB::table('users')
            ->join('characters', function($join)
            {
                $join->on('users.id', '=', 'characters.user_id')
                ->where('users.username', '=', Session::get('theuser'));
            })
            ->get();

            if($resultchar == false) {
                return Redirect::route('create-character');

            } else {

                $selected_char = User::find(Auth::user()->id)->character()->whereRaw('lord_id = id')->first()->char_name;                                                   
                return Redirect::route('char-profile-get', array(Auth::user()->username))
                ->with('selected_char',$selected_char);


            }
        }
        else {



            return Redirect::route('home')
            ->with('global', 'Email/password wrong, or account not activated');


        }
    }

    return Redirect::route('home')
    ->with('global', 'There is a problem signing you in');
}

因此,如果用户从未创建过角色,那么就应该这样做

return Redirect::route('create-character');

代码到达此行,但不是将我重定向到/public/account/create-char,而是将我重定向到主页/public/

.htaccess文件如下所示:

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /public/index.php?$1 [PT,L]

</IfModule>

与数据库的通信有效,因为服务器识别哪个帐户是新帐户,哪个帐户是旧帐户。使用旧帐户时,它会尝试将我重定向到另一个路径,但最终会在主页面中显示。注册也有效,在重定向之前,用户被添加到DB的用户表中。

如果我要添加更多详细信息或代码,请告诉我。

0 个答案:

没有答案