 |

08-14-2006, 03:23 PM
|
|
WebProWorld Pro
|
|
Join Date: Aug 2006
Location: Cary, Illinois
Posts: 160
|
|
Changing Home page from HTML to PHP - Redirect question
Hi...I apologize if this topic has already come up; I could not find the EXACT condition I am facing.
I'd like to change my home page from a standard HTML to a PHP. (I am not changing domain names). In order to not disturb other sites linking to me, I'd like to change my existing index.html to only redirect to the new index.php page.
Which is the best and safest way to do this without having Google/Yahoo/MSN think my old page has disappeared (and subsequently be placed in the big sandbox in the sky)? I ONLY have a PR 2; I don't
want to lose that!
Thanks!
|

08-14-2006, 03:40 PM
|
|
WebProWorld Member
|
|
Join Date: Jul 2003
Location: Boston, MA
Posts: 60
|
|
I don't know if this will affect your rankings but you can use JavaScript in your HTML page to send users to your PHP page.
Code:
<SCRIPT LANGUAGE="JavaScript">
<!--
window.location="http://www.yourdomain.com/";
// -->
</script>
Anyone know if this will affect the ranking?
|

08-14-2006, 05:33 PM
|
|
WebProWorld Pro
|
|
Join Date: Aug 2006
Location: Cary, Illinois
Posts: 160
|
|
Adamwlad:
I did some more checking and found an html version as well as your javascript example. The only problem I read was the redirect won't work if the user does not have javascript enabled. The information I found made no mention of the effects on Google/Yahoo/MSN...
|

08-14-2006, 07:11 PM
|
|
WebProWorld 1,000+ Club
|
|
Join Date: Jul 2003
Location: United Kingdom
Posts: 1,712
|
|
change my home page from a standard HTML to a PHP.
Quote:
|
Change my home page from a standard HTML to a PHP.
|
Why?? For more dynamic!!
You can embed dynamic PHP within a HTML, (.html) page
Using code similar to this: -
Code:
<?php
include("http://www.comparebargains.com/search.php?keywords=software&call_from_html_page=1");
?>
The page could also have HTML code in it.
If done correctly the search engines, and users, will not see any differences except that the .HTML page will be more dynamic.
|

08-14-2006, 07:13 PM
|
|
WebProWorld Member
|
|
Join Date: Feb 2004
Location: Stupid question. At my PC.
Posts: 99
|
|
I strongly advise against using a JavaScript redirect. Using a JavaScript redirect can be a kiss of death with Google. It resembles a JavaScript cloaking technique used by a Las Vegas SEO company a few years ago. Google banned all of the company's clients' sites that used this technique.
Also, most search engines cannot follow JavaScript redirects. It's the same issue with most JavaScript menu systems.
The real question is, why do you want to change from HTML to PHP? If you just want to change from a static page site to a dynamic site, and you are on an Apache server that allows you to use the .htaccess file, you can add a command to the file that will execute HTML pages as if they were PHP scripts.
Just add the following to the .htaccess file found in the root directory.
AddType application/x-httpd-php .html
You can then leave the .html extensions on your Web pages and not risk starting over with the search engines. This sends an .html page through the PHP parser and executes the code just like if it was a PHP script.
There are other alternatives, but this is probably the simplest way to do it. I assume you are talking about turning more than just the home page into a PHP script.
If you just want to use a PHP script for the home page only, you could change all of the links within the site to an absolute link that does not use the home page file name.
http://www.mydomainname.com/
If a search engine does not find a link such as index.php or index.html, it lets the server use the default page and the recognized home page URL becomes http://www.mydomainname.com/.
You do not need to add index.html or index.php to a home page URL. Hope this helps.
|

08-14-2006, 07:53 PM
|
 |
WebProWorld Veteran
|
|
Join Date: Sep 2003
Location: Halton Hills, ON
Posts: 578
|
|
The proper way is using the .htaccess.
Rather than instructing it to parse .htm as .php you can redirect it for the search engines as well as site visitors and existing links using the 301 redirect.
Here's the code:
redirect 301 /index.html http://www.domainname.com/index.php
|

08-14-2006, 07:54 PM
|
 |
WebProWorld Member
|
|
Join Date: Aug 2005
Location: Hong Kong & Philippines
Posts: 60
|
|
It might be a primitive method but I have done this a few times.
If you only want to change the home page just create a duplicate of your home page and change the extension to .php then ensure links on you sites go to index.php not index.html.
Change the header of index.html to include a refresh/redirect to index.php
If you are using Cpanel you probably have the server redirects option so instead of changing the header of index.html you can simply set up a redirect on the server to redirct index.html traffic to index.php
|

08-14-2006, 09:13 PM
|
 |
WebProWorld 1,000+ Club
|
|
Join Date: Apr 2005
Location: Delaware Valley, PA
Posts: 1,186
|
|
This is the way I do it. I put these two lines in my .htaccess file:
Code:
AddType application/x-httpd-php htm html php
AddHandler application/x-httpd-php .htm .html
Then I simply change the extension on my index.php to index.html or whatever it was originally. This allows the server to parse php on any page regardless of whether its file extension is htm, html, or php. So you don't have to rename your index page in order to use php, nor do you have to redirect. Clean and simple.
Oh, and I might add that if you decide to add php includes on other pages you won't need to worry about changing any of the page name/file extensions, they'll all work. So it's not an index page fix, it's a sitewide fix.
|

08-14-2006, 09:31 PM
|
|
WebProWorld Pro
|
|
Join Date: Aug 2006
Location: Cary, Illinois
Posts: 160
|
|
WOW! A lot of great responses! All my sub-pages are already .php but did not think in the beginning I would ever need mysql on my home page. I recently had bad reviews on my home page (my very-first web site) and wanted to brighten it up with new products, featured products, etc. And by also adding randomizing code, I would have zero maintenance.
My biggest fear was to tamper with my already-low PR with Google.
Based on the great comments, it appears the .htaccess file method is the way to go. (I assume this file already exists on my root directory?)
Thank you ALL very much for your help!
JR-getmea
|

08-14-2006, 09:42 PM
|
 |
WebProWorld 1,000+ Club
|
|
Join Date: Apr 2005
Location: Delaware Valley, PA
Posts: 1,186
|
|
If there is no .htaccess file you can simply create one in your cpanel filemanager or use notepad and upload it. Some webhosts make you use the filemanager in cpanel (or plesk) to upload the .htaccess file for security reasons instead of allowing ftp of it, so if you find you can't ftp it, try the filemanager for your webhosting.
|

08-14-2006, 10:06 PM
|
|
WebProWorld Member
|
|
Join Date: Jul 2006
Location: Oakland, CA
Posts: 45
|
|
changing from html to php
As a web developer and search engine marketer, my take on this issue is this.
- you run the risk of loosing your PR and will have to start all over
- or run the risk of your PHP page being considered as just a duplicate of your former html page
- the use of the htaccess command RewriteRule ^yourfilename.php$ yourfilename.html should solve the problem.
What will happen in a few months or years later if you decide to change the server-side programming language, say from PHP to ColdFusion or ASP?
Would you have to change your file extensions from .php to .cfm or .asp?
If your server allow you to ahve an htaccess file the use it without even having to need a redirect 301
On the other hand if your web host does not permit the use of the htaccess file, then take your business elsewhere.
Hope this modest contribution will be useful to ALL.
|

08-14-2006, 10:17 PM
|
 |
WebProWorld 1,000+ Club
|
|
Join Date: Apr 2005
Location: Delaware Valley, PA
Posts: 1,186
|
|
Quote:
What will happen in a few months or years later if you decide to change the server-side programming language, say from PHP to ColdFusing or ASP?
Would you have to change your file extensions from .php to .cfm or .asp?
|
I should think it would be the other way around, holyhttp. :)
|

08-14-2006, 10:55 PM
|
|
WebProWorld Member
|
|
Join Date: Jul 2006
Location: Oakland, CA
Posts: 45
|
|
html to php
Qote:
I should think it would be the other way around, holyhttp. :)
Thanks for your input bj.
The original question was migrating from static page html to php hence changing the file extension from html to php. Following the same logic say, now going from php to asp would be to change the old extension to the new one. Isn't it?
Using html extensions thanks to the htaccess now allows us to make the file naming independent of the server-side programming language used.
Oh well, thanks ALL for your great contribution. I have been a spectator for quite a while and now decide to get really involved and share my insights.
|

08-15-2006, 04:01 AM
|
|
WebProWorld Member
|
|
Join Date: Nov 2005
Posts: 66
|
|
.ht acesss
TechEvangelist and BJ are correct - use the .htaccess file to tell your server to process php within .htm/.html files - no need for any change of URLs.
|

08-15-2006, 05:58 AM
|
|
WebProWorld Veteran
|
|
Join Date: Jul 2003
Location: Spain
Posts: 331
|
|
Quote:
|
Originally Posted by Skywoolf
It might be a primitive method but I have done this a few times.
If you only want to change the home page just create a duplicate of your home page and change the extension to .php
|
Right on the button. Even if you don't have any PHP in the HTML page, then .php extensions will work. You lose a squillionth of a second whilst the server looks for any php in the page, and in the real world, it will be unnoticable.
Quote:
|
Originally Posted by Skywoolf
then ensure links on you sites go to index.php not index.html.
|
Not happy about this, there are some who thing that that link to MydomainDotCom/index.whatever leads to duplicate content concerns, and also PR split. I always try to have internal links to the home page going to MydomainDotCom/ - the trailing slash is a plus, it will work without it, but slightly more slowly.
Quote:
|
Originally Posted by Skywoolf
Change the header of index.html to include a refresh/redirect to index.php
|
I would have thought that most of the useful links to this page are from other sites, and not your own site. How many people actually put MydomainDotCom/index.html in their links to you? It's more usually simply MydomainDotCom. So all you need to do is rename index.html to index.php
|

08-15-2006, 09:52 AM
|
 |
WebProWorld 1,000+ Club
|
|
Join Date: Apr 2005
Location: Delaware Valley, PA
Posts: 1,186
|
|
Okay, mnsandy, this is what I want you to do, and we'll see if it has an effect or not. Change your homepage file extension the way you just (ill) advised getmea to do. And don't do anything else since you said you always link to your domain without using the filename. In a week or two take a look at your stats, then report back and let us know what happened . . .
I think if you do that you won't ever give that advice again.
|

08-15-2006, 10:02 AM
|
|
WebProWorld Member
|
|
Join Date: Jul 2003
Location: Boston, MA
Posts: 60
|
|
anyone know if Google will ban your site from their results if you use the META tag redirect?
|

08-15-2006, 12:01 PM
|
 |
Moderator
|
|
Join Date: Jan 2004
Location: Live in Cincy Now
Posts: 7,597
|
|
Quote:
|
Originally Posted by Adamwlad
anyone know if Google will ban your site from their results if you use the META tag redirect?
|
Who knows if they will demote you or not for sure, but I know not to use one and I will tell everyone in this forum not to use one becuase they are frowned upon by the SE's.
|

08-15-2006, 12:04 PM
|
 |
Moderator
|
|
Join Date: Jan 2004
Location: Live in Cincy Now
Posts: 7,597
|
|
Quote:
|
Originally Posted by getmea
WOW! A lot of great responses! All my sub-pages are already .php but did not think in the beginning I would ever need mysql on my home page. I recently had bad reviews on my home page (my very-first web site) and wanted to brighten it up with new products, featured products, etc. And by also adding randomizing code, I would have zero maintenance.
My biggest fear was to tamper with my already-low PR with Google.
Based on the great comments, it appears the .htaccess file method is the way to go. (I assume this file already exists on my root directory?)
Thank you ALL very much for your help!
JR-getmea
|
So your sub-pages don't need changed and either does your home page. The search engine sees your home page as www.domain.com not www.domain.com/index.html as mnsandy pointed out. If you are pointing internal links on your website to your home page using a relative link like /index.html then stop doing that and send them to www.domain.com. You should be bale to change your default server doc anytime without PR changes, rankings drops, etc.
|
|