Forum Moderators: coopster

Message Too Old, No Replies

How do I have a Html include direct to the PHP index

someone accesses "content.html" how do I direct them to my index.php

         

Flash72

11:07 pm on May 27, 2004 (gmt 0)

10+ Year Member



Hello, Yes I'm new both to this forum and PHP. Both of which I've come to admire.

I have an index.php file
which contains:
a header include header.html
a content include content.html (content1.html, etc)
a footer include footer.html

The content.html is actaully severval files which can be called up by array content1.html, content2.html, etc.

My question is what if someone (including Google)goes to www.mypage.com/content.html, how do I make it so it directs them to index.php which will then load that content.html as part of the index.php page.

I guess part two of my question would be is this a bad idea to have several content.html files. I inherited a frames website, which has several .html elements which I feel can easily be used in this manner basically 15-20 content.html files (arrayed) per index.php

I have all the includes in one folder with "root" links, so everything works.

I don't want to lose page ranking. And the site has over 200 pages.

Flash72

11:42 pm on May 27, 2004 (gmt 0)

10+ Year Member



The site is already indexed in google. So if someone finds content1.html, they would be taken to just that part of the page, no header, footer, etc. That is why I want it to redirect (if this is a good idea) to the index.php.

Here is the code inside index.php for the content.html section:

<div id="content">

<?php
$links = array('content1.html', 'content2.html', 'content3.html',); // define the array - links
if (isset($_GET['page'])) { // if the $page is set
if(in_array($page,$links)) { // if page is in the array
include($page); // include $page
} // end include page if in array statement
else { // if $page is NOT in the array
echo "page not available"; // display a warning
exit(); // end page running
}; // end else statement
} // end if page isnt set statement
else { // if $page is NOT set
include("content_main.html"); // include default page
}; // end if $page is NOT set statement

?>

coopster

6:41 pm on May 29, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, Flash72!

PHP has a header() [php.net] function that can be used to redirect, there is an example in the manual page of the link provided.

Also, if your web server is Apache, you may want to check in the mod_rewrite [httpd.apache.org] module.