'Google App Engine (PHP) - redirected you too many times

I am trying to work on redirecting to a page on Google App Engine because due to changes from php55 to php74, the script variable in app.yaml requires it to be set as auto (meaning I need to have an index.php set up). Because of that complication, I get an error where it says I get redirected too many times. I tested this on my local machine, but once I deploy it on GAE, it get that redirect issue.

app.yaml

runtime: php74

handlers:
  - url: /.*
    script: auto

index.php

<?php
header("Location: login.php");
exit();
?>

login.php

<?php
include("header.inc");
?>

<?php

session_start();

use google\appengine\api\users\User;
use google\appengine\api\users\UserService;
use Google\Cloud\DataStore\DatastoreClient;

# Includes the autoloader for libraries installed with composer
require __DIR__ . '/vendor/autoload.php';

use Google\Cloud\Storage\StorageClient;

# Your Google Cloud Platform project ID
$projectId = '---';

# Instantiates a client
$datastore = new DatastoreClient([
    'projectId' => $projectId
]);

// Test to see if auth actually works
echo "Hello World!"

?>

<form method="post">
<!--    <div class="form-group">-->
<!--        <label for="username">Username</label>-->
<!--        <input type="text" class="form-control" name="username" placeholder="Enter Username">-->
<!--    </div>-->
<!--    <div>-->
<!--        <div class="form-group">-->
<!--            <label for="password">Password</label>-->
<!--            <input type="password" class="form-control" name="password" placeholder="Enter Password">-->
<!--        </div>-->
<!--    </div>-->
<!--    <div-->
<!--    ">-->
<!--    <button type="submit" class="btn btn-primary">Login</button>-->
<!--    </div>-->
<!--    <div>-->
<!--        <button type="Register" href="register.php">Register</button>-->
<!--    </div>-->
<!--    </div>-->
</form>

<?php
include("footer.inc");
?>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source