Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用Slim 2.6和Twig重定向问题_Php_.htaccess_Redirect_Twig_Slim - Fatal编程技术网

Php 使用Slim 2.6和Twig重定向问题

Php 使用Slim 2.6和Twig重定向问题,php,.htaccess,redirect,twig,slim,Php,.htaccess,Redirect,Twig,Slim,在一个本地WAMP服务器上,我有一个使用Twig和Slim(as)构建的网站,它可以顺利运行。但是,在远程服务器上运行时,会出现重定向问题 也就是说,app/routes/auth/register.php中的行$app->response->redirect($app->urlFor('home'))在地址栏“scrumphd.dreamhosters.com/public/register”中给出了一个空白页,其中包含以下内容,尽管事实上回声$app->->urlFor('home')给出了

在一个本地WAMP服务器上,我有一个使用Twig和Slim(as)构建的网站,它可以顺利运行。但是,在远程服务器上运行时,会出现重定向问题

也就是说,app/routes/auth/register.php中的行
$app->response->redirect($app->urlFor('home'))
在地址栏“scrumphd.dreamhosters.com/public/register”中给出了一个空白页,其中包含以下内容,尽管事实上回声
$app->->urlFor('home')
给出了“/public/”

到目前为止,我已经尝试在app->config->production.php下更改url,并将其重定向到指定的url和其他路由。我觉得问题可能出在配置文件、.htaccess或app/start.php文件上。不幸的是,该网页没有呈现任何错误,因此我发现无法调试

下面是令人讨厌的register.php,其重定向位于post路由的末尾:

<?php

use PhD\User\UserPermission;

$app->get('/register', $guest(), function() use ($app) {
    $app->render('auth/register.php');
})->name('register');

$app->post('/register', $guest(), function() use ($app) {

    $request = $app->request;

    $email = $request->post('email');
    $username = $request->post('username');
    $password = $request->post('password');
    $passwordConfirm = $request->post('password_confirm');

    $v = $app->validation;

    $v->validate([
        'email' => [$email, 'required|email|uniqueEmail'],
        'username' => [$username, 'required|alnumDash|max(20)|uniqueUsername'],
        'password' => [$password, 'required|min(6)'],
        'password_confirm' => [$passwordConfirm, 'required|matches(password)']
    ]);

    if ($v->passes()) {

        $identifier = $app->randomlib->generateString(128);

        $user = $app->user->create([
            'email' => $email,
            'username' => $username,
            'password' => $app->hash->password($password),
            'active' => false,
            'active_hash' => $app->hash->hash($identifier),
        ]);

        $user->permissions()->create(UserPermission::$defaults);

        $app->mail->send('email/auth/registered.php', ['user' => $user, 'identifier' => $identifier], function($message) use ($user) {
            $message->to($user->email);
            $message->subject('Thanks for registering.');
        });

        $app->mail->send('email/auth/notification.php', ['user' => $user], function($message) use ($user) {
            $message->to('james.clarke11@imperial.ac.uk');
            $message->subject('New registered user!');
        });

        $app->flash('global', 'You have been registered.');
        $app->response->redirect($app->urlFor('home'));
    }

    $app->render('auth/register.php', [
        'errors' => $v->errors(),
        'request' => $request
    ]);





})->name('register.post');

您是否尝试过使用
$app->redirect($app->urlFor('home')。甚至是
return$app->redi..
内容没有呈现?我尝试了后者,但我不确定前者。我会尝试一下,并留下一个关于它是否有效的更新。你是否尝试过使用
$app->redirect($app->urlFor('home')。甚至是
return$app->redi..
内容没有呈现?我尝试了后者,但我不确定前者。我会尝试一下,并留下一个是否有效的更新。