Redirect to folder

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JF3000
Forum Newbie
Posts: 19
Joined: Tue Mar 01, 2005 2:54 am

Redirect to folder

Post by JF3000 »

Hi,

I know this line that goes at the beginning of the page will redirect the user to that file.

Code: Select all

<?php  include('index_default.php'); ?>
In my phpBB folder I was to place a command in the index.php at the top to tell the page not to load and go to a folder in the same directory, is it as easy as :

Code: Select all

<?php  include('foldername/index.php'); ?>
??

Thank you.

JF3000
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

The answer to your question appears to be Only if the your current file has no output but the redirected file does. I would like to try to clarify a possible misconception...

Include does not "move" the user to the indicated page. It actually inserts the indicated file into the current file. http://www.php.net/manual/en/function.include.php

To "move" you would use the command header("Location: newlocation.php"); This would change the url bar at the top of the browser. By using "include" this browser relocation does not happen.

Hope that clarifies things a bit.
JF3000
Forum Newbie
Posts: 19
Joined: Tue Mar 01, 2005 2:54 am

Post by JF3000 »

I am totally lost by what you say, here is my predictament :

I have phpBB installed, I have a frontend of a phpBB done in flash, the location of the forum in flash is phpBB/Flashbb

If you go to the website with websitehere.com/phpBB/Flashbb the site loads the flash phpbb, but if you just went there normally :

websitehere.com/phpBB then it loads the basic phpBB website.

What I would like to be able to do is mvoe the user from the websitehere.com/phpBB/index.php area to the websitehere.com/phpBB/FlashBB/index.php area.

Hope this makes a little more sense.

I didnt know what include meant, im still trying to understand everything everyone tells me so thank you for the reply though.

JF3000
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Code: Select all

<?php header('location: index_default.php'); ?>
Right at the VERY top of the page that will force the redirect....
JF3000
Forum Newbie
Posts: 19
Joined: Tue Mar 01, 2005 2:54 am

Post by JF3000 »

So where it says location, if I place FlashBB and the other bit as index.php and place this in the index.php file located in the phpBB file this will force the user to the other area?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Yes. Test it :wink:

If it doesn't work first time play around with which file it needs to be until it does work.

In other words... whatver loads by default needs to redirect, so put the header('location:... code at the top of the default file to force a redirect
Post Reply