Purdy
Purdy

Reputation: 66

Redirect loop with AppEngine and CodeIgniter PHP when deploying to production

I just deployed my CodeIgniter PHP AppEngine project to the cloud and I'm running into an issue where when I try to access one of my URL's, it results in a redirect loop. I've tried using different browsers & incognito modes, but they still result in the same problem.

I setup one URL in my app.yaml and it does work.

- url: /tos
  script: tos.php

So then the /tos works.

But for my regular CodeIngiter index.php program, it results in the redirect loop and it fizzles out with some long URL in the address bar. Here's the relevant app.yaml:

- url: .*
  script: index.php

http://even-crossing-385.appspot.com/base/data/home/apps/s~even-crossing-385/1.371577713118072254/login

Works fine on my local development box.

Am I missing some sort of configuration here?

Thanks!

Upvotes: 1

Views: 440

Answers (4)

user2744119
user2744119

Reputation: 153

I had the opposite effect. It wasn't working locally with the App Engine SDK but when I deployed it to GAE it worked perfectly. The "hack of CodeIgniter" described in this thread didn't work for me. I finally got it to work by modifying the config.php file in application/config/config.php

I commented out the existing config settings for base_url, index_page and uri_protocol and replaced it with the following:

if(isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'],'Google App Engine') !== false)
{
//Production settings go here
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
}
else
{
//Local Development settings go here (change "13080" to whatever number the localhost SDK generates for you )
$config['base_url'] = 'http://localhost:13080/';
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'PATH_INFO';
}

To be honest I have no clue why this worked but it did.

Upvotes: 0

Thato
Thato

Reputation: 3

- url: /
  script: ci-googleappengine-test/index.php

- url: /(.+)
  script: ci-googleappengine-test/index.php

it will work, worked for me. ci-googleappengine-test = folder name

Upvotes: 0

Purdy
Purdy

Reputation: 66

I couldn't get this to work, but I ended up finding this hack of CodeIgniter that worked both locally and on AppEngine. So I used it and copied my controllers, models and views over there and then everything was find. My guess is that there's some sort of underlying environment variables that aren't working when it goes into production.

Upvotes: 0

Jesus Trujillo Garcia
Jesus Trujillo Garcia

Reputation: 41

I have the same problem, in my local computer with WAMP it works fine, but using google app engine it only shows the default controller, I think the problem is the file app.yaml but I can not setup the redirect rules fine

Upvotes: 1

Related Questions