Forum Moderators: coopster
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.
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
?>
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.