Jump to content

Is there a trick to redirection?


Go to solution Solved by opentype,

Recommended Posts

Posted (edited)

I am on the hosted platform, but no access to email support yet.  I am using only the following code in a custom php block.

header("Location: https://myazurebox/id=". $_COOKIE["ips4_member_id"]);

When I call this block, nothing happens.    I can see the cookies are there.

If I add the exit command:

header("Location: https://myazurebox?id=". $_COOKIE["ips4_member_id"]);
exit();

I receive a generic error when I try to save the block.

Sorry!  The page you requested does not exist
Error code: 1S160/2

Edited by MartinLawrence
removed private info
Posted

Blocks are parsed in the body. In order for the header() function to execute, it must be done before any output is sent. 

So I don’t think you can actually do redirects within blocks… instead, I believe you might want to do this within your term with template logic. 

Someone else can keep me honest on this however as I’m not a coder.  I just do system administration.  🙂 

  • Solution
Posted
7 minutes ago, Randy Calvert said:

I believe you might want to do this within your term with template logic. 

A template redirect looks like this:

{{\IPS\Output::i()->redirect('https://server.com/something.htm');}}

 

Posted
3 hours ago, opentype said:

A template redirect looks like this:

{{\IPS\Output::i()->redirect('https://server.com/something.htm');}}

 

Thank you.  I made a new page with just this on it and it worked great.  Thanks!

How would I go about appending a cookie to that? 

. $_COOKIE["ips4_member_id"]');}}

Comes out as this after redirection.

="%20.%20$_COOKIE["ips4_member_id"]

 

Posted

Haven’t tested it. Might just be the space around the period character. 

When in doubt you can create the redirect target in a separate line. 

{{$target="https://test.com/".$something;}}
{{\IPS\Output::i()->redirect($target);}}

Should work. 

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...