Forum Moderators: coopster

Message Too Old, No Replies

Changed site from .htm to .php

How can I redirect access from old urls?

         

Quillspirit

4:36 pm on Jul 6, 2006 (gmt 0)

10+ Year Member



I have changed my website from .htm/.html to .php so I can use header/footer includes to make my site more uniform and use .php code throughout the site...


<?
session_start();

$meta_pagetitle="... ";
$meta_keywords=" ... ";
$meta_description=" ... ";
include('./inc/header.html');
include('./inc/index.html');
include('./inc/footer.html');

?>

So now my site is nice and pretty.

Problem is, search engines (like google) still have the .htm/.html pages in their index, which point to the raw data, without the header/footer (Including the <body> tag, meta keywords/desc/title, navigation menu, and copyright notice in the footer... not to forget my adsense ads!)

So, if somebody accesses a .htm/.html url directly, there is no way for them to really navigate the site.

Is there anything I can put in the .htm/.html pages to check the url in the browser, and if it is .htm/.html, redirect to the .php page?

I have placed

User-Agent: *
Disallow: /*.htm$
Disallow: /*.html$

in my robots.txt, but I figure it may take a long time for these pages to drop out of the SE's. It is a very large site (thousands of pages... genealogy/history data).

Help?!?

Quillspirit

4:40 pm on Jul 6, 2006 (gmt 0)

10+ Year Member



(P.S. - The solution will have to be in Javascript or something, because .php won't work on a straight .html page)

Maybe the redirect can be done with .htaccess, but I'm thinking it would cause a bad loop, since the same page is being included via .php?

Quillspirit

5:02 pm on Jul 6, 2006 (gmt 0)

10+ Year Member



Nevermind... SOLVED. I just did .htaccess redirects. Works fine. :)