i'm not sure how to ask my question but here's a shot.
i want to process (i think all) requests to my server (apache) by a php file. the file would call to include a menu, a login, a comments file, and the file requested. i suppose one way to do this would be to have apache always redirect to this php file, passing in the requested file's name? i could do this with the missing file option
im looking for the easiest and least-silly way of doing this.. i could make all my pages redirect to the missing file.. and then have the missing file process the request.. but that seems silly
am I silly for wanting to do this.. whats a better way. i havent found many answers because i dont know what im searchign for? are people already doing this.. waht do they call it...
process all page requests by one file
Moderator: General Moderators
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
If i understand your question fully you want to load all pages on your site from one single page - i.e. all requests go to index.php, but depending on an added variable it will show a different page to the user. This is very common and very easy to do. There is lots of threads in the forum that discus doing this but as a quick tip...
page called: index.php?page=contact
Then you will want to get more complex and check the file that the user is requesting to make sure its ok to show them it, and add more error checking etc. But that is the basic principle of it. Just include that code in the page template and then the page will always look the same - just with a different main content. You can then do the same with the menus if you wish.
page called: index.php?page=contact
Code: Select all
if(isset($_GET['page'])){
include('some/path/'.$_GET['page'].'.php');
}else{
include('some/path/home.php');
}yes actually that is waht im doing now, but i dont have a way of sending all page requests, or file requests through my index.php should i just rename my files to .inc so they wont "exist" and then have all page not found errors handled by my index.php.. isnt there a smarter way of doing this? do i realy want to do this? what are reasons not to...
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England