PDA

View Full Version : In need of a piece of code


Creechur
11-15-2002, 01:00 PM
I am in need of a code snippet that will allow me to redirect a page automatically. To be a little more clear i am looking for the php equivilent of the html meta tage refresh.

I am using a ported version of PhP-nuke and since the "module" links are coded to look for names i can reassign the link i want to go to another page. So here is my set up:

I have a main portal ie:

www.mysite.com ( has a forum set up )

and multiple domains ie:

sub1.mysite.com (same basic look but no forum)

I want sub1.mysite.com 's forum index.php to auto forward ( in it's "self" ) to www.mysite.com's forum folder


So in other words when a user clicks on the forums module ( a folder with just and index.php file in ) the it will open the index file and auto refresh to www.mysite.com/modules/forums/ but retain itself in the same page so you are essentially seeing the sub1.mysite.com but the main window ($self) is displaying the forums page from mysite.com.

Does that make sense?

Grizzly
11-15-2002, 02:01 PM
header("Location: http://www.mysite.com/modules/forums/");

Creechur
11-15-2002, 03:21 PM
Yeah I used that, but it opens up the root folder rather than directing it to the other address.


So the file is on sub1.mysite.com/modules/forums/index.php and refers to www.mysite.com/html/modules/moduels.php?name=Forums....

but it redirects to :

sub1.mysite.com/modules.php?name=Forums

So it's ignoring the location address.

Any ideas?

Uranium-235
11-15-2002, 06:03 PM
i'ts a header thing

just do:

<META HTTP-EQUIV=Refresh CONTENT="1; URL=http://www.mysite.com/">

Grizzly
11-15-2002, 08:24 PM
Originally posted by Uranium-235
i'ts a header thing

just do:

<META HTTP-EQUIV=Refresh CONTENT="1; URL=http://www.mysite.com/">

That's *precisely* what the PHP function call I posted above does. Either way you want to slice it, you're just sending out a new HTTP-Location header.

To Creechur - I really don't understand what problem you're having. Care to rephrase your question?

roninblade
11-15-2002, 09:08 PM
the only problem with header relocation is you cant output anything to the browser before calling the function. if you want to display anything before redirecting, you better use either meta redirection or javascript.

Grizzly
11-15-2002, 10:08 PM
Well - a lot of people use the output buffering functionality built into PHP to get around that. ob_start() (http://www.php.net/manual/en/function.ob-start.php) is all you really need to do.

Creechur
11-18-2002, 04:33 PM
ok here is what i want it to do.


site all has the same layout, just different looks and menu locations.

so the main page ( www.mysite.com ) has menus for mysite.com. It also houses the forums folder.

Now when you go to sub1 ( sub1.mysite.com) its looks just like mysite.com but its int its own fodler oin a subdomain.

What I want is for the lefthand menu on sub1.mysite.com to stay the same but when you click the forum link it retains the sub1.mysite.com menus but shows you the www.mysite.com forum.


you can see what I'm doing at

http://www.erovrar.com/html/ ( www.mysite.com)

and

http://gh.erovrar.com (sub1.mysite.com)

click on the forum link on gh.erorvar.com

skidooer
11-18-2002, 04:46 PM
Originally posted by Uranium-235
i'ts a header thing

just do:

<META HTTP-EQUIV=Refresh CONTENT="1; URL=http://www.mysite.com/">
Why use HTTP-EQUIV when you can put the header right into the HTTP response?

Uranium-235
11-18-2002, 07:42 PM
Originally posted by skidooer
Why use HTTP-EQUIV when you can put the header right into the HTTP response?

because of this...

Originally posted by Creechur
Yeah I used that, but it opens up the root folder rather than directing it to the other address.


So the file is on sub1.mysite.com/modules/forums/index.php and refers to www.mysite.com/html/modules/moduels.php?name=Forums....

but it redirects to :

sub1.mysite.com/modules.php?name=Forums

So it's ignoring the location address.

Any ideas?