How can I use PHP to create a redirection of something like:
http://mybb.com/jasoniscool.php?id=hi
to redirect to
http://google.com
pyridine wrote me this line of htaccess to try and it unfortunately failed. So I am looking for a PHP one instead.
RewriteRule blog-script/jason.php?id=hi http://google.com [R,NC]
Umm... yes it'll work for him
if($mybb->input['id'] == 1)
{
http_redirect("http://google.com);
}
EDIT: But Jason, don't PM me for support like that anymore, thanks
(2011-09-25, 04:52 AM)Dylan M. Wrote: [ -> ]Umm... yes it'll work for him
if($mybb->input['id'] == 1)
{
http_redirect("http://google.com);
}
EDIT: But Jason, don't PM me for support like that anymore, thanks
This wont be for MyBB (reasoning why its not in support or something else) so how can I go about editing that to where its just for a normal page?
Sorry.
Replace the $mybb->input with the appropriate input class if you're using one, or $_GET if you aren't.
(2011-09-25, 05:02 AM)Dylan M. Wrote: [ -> ]Replace the $mybb->input with the appropriate input class if you're using one, or $_GET if you aren't.
<?php
if($_GET['id'] == 1)
{
http_redirect("http://google.com);
}
?>
Quote:Parse error: syntax error, unexpected $end in /home/jasonl/public_html/blog-script/sponsors.php on line 8
UPDATE: Seems you made a mini type and forgot the " after google. However, now I get
Quote:Fatal error: Call to undefined function http_redirect() in /home/jasonl/public_html/blog-script/sponsors.php on line 5
Can I fix it by starting outbound buffering and then placing a header location function in there?
I fixed it myself with this code incase anyone is interested.
<?php
ob_start();
session_start();
if($_GET['id'] == 1)
{
ob_end_clean();
header( 'Location: http://google.com' ) ;
exit;
}
?>
To use http_redirect() you need to have the PECL extensions installed on your server. Otherwise you're limited to the header() instead.
(2011-09-25, 03:38 PM)Dylan M. Wrote: [ -> ]To use http_redirect() you need to have the PECL extensions installed on your server. Otherwise you're limited to the header() instead.
I already fixed it with the code I provided above.
demo
Sometimes, easy to do scripts makes our jobs tedious.