ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Using PHP Code in ExpressionEngine - PHP Redirect Not Working - "Object Moved" message instead of Redirect.

December 19, 2012 9:46am

Subscribe [2]
  • #1 / Dec 19, 2012 9:46am

    shuffm

    2 posts

    Hello, I’m not a PHP expert or EE expert.  I’ve tried solving this problem, but I can’t and need help. 

    I have a site I’m building in EE (latest version).

    There is a page at…

    http://dev.pulaskiticketsandtours.com/agent

    ...where I am simply trying to test a redirect for a failed login.

    It is not working.

    The template is set to allow PHP and the parsing stage is set to Input.

    The first line of code is this:

    <?php
    session_start();
    if ( !isset($_SESSION['test']) ){
     header("location:http://dev.pulaskiticketsandtours.com");
    }
    ?>

    Instead of redirecting, it loads the page with this as the header:

    Object Moved This document may be found here

    The exact same code works on a test page I created at…

    http://dev.pulaskiticketsandtours.com/test.php

    ...so the issue seems confined to the Expression Engine template/environment.

    So far, I can get PHP to do anything I need to outside of EE, but this is my first try of putting PHP inside EE system.  I’ve tried include files…everything..and scoured the net…can’t find a solution…and it seems like it should be pretty easy.

    I am using IIS7.5 with URL rewrite, but so far everything has worked fine, and like I said…I can get this to work on the test page outside of EE.  I’m totally at a loss.

    Please help someone!  Thanks!

  • #2 / Dec 19, 2012 10:44am

    benjamin-smith

    1 posts

    Have you tried this answer at the end of this post?

    Your new code would be (untested):

    <?php
    session_start();
    if ( !isset($_SESSION['test']) ){
     header("location:http://dev.pulaskiticketsandtours.com");
    }
    exit();
    ?>
  • #3 / Dec 19, 2012 11:06am

    shuffm

    2 posts

    That was it!  Thanks, man!

    The HOW has been delivered.

    One day, I’ll understand WHY.

    exit(this_problem) and on to new ones.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases