PDA

View Full Version : Does using .php adversely affect your page rank?



kuau
12-29-2007, 12:49 AM
I inherited a website last July that was all done in frames and images (ie. text was actually a photo of text), but the file extensions were .html. There were no meta-tags, no page titles, and the only pages that had real text were the home page (a few sentences) and about-us page. Nevertheless, the site had a page-rank of 3 (!). I rewrote the entire site using SEO-friendly practices (added meta-tags, used all real text, removed all tables and did everything in pure css using php includes, added a ton of content, used <h1> tags etc).

Because of Yahoo's hosting limitations (no .htaccess), I had to change all the file extensions to .php. I did redirects for all the html files in the only way I could without server access or an .htaccess file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>HTTP/1.1 301 Moved Permanently</title>
<meta http-equiv="refresh" content="0;URL=http://www.sargentsfineart.com/index.php">
</head>
<body>
</body>
</html>

After all that effort, you would think the page rank would have gone way up, but instead it went down to 2!!

So my question is, do the Google search engines rank .html page extensions higher than .php file extensions? Or do they assume that .php means that the file is all code and just skip them? Or how do you explain the drop in the page rank? It is very discouraging to say the least. I figure if anyone would know, it would be you guys, so please elucidate this for me.

Thanks very much. erin :)

PS. In case this is a factor, I should mention that I created all the pages (except the homepage, about us etc) as dynamic pages loading the content data from a mySQL database into templates filled with php variables. But I was told that bots view the pages in their rendered states, just as a viewer would see them. I hope this is true. (?)

Twey
12-29-2007, 12:54 AM
It is generally true, but doing redirects for the HTML pages in this way (without using the correct status code) probably means that the search engine still indexed them, and ranked the page lower thanks to all these contentless pages. You'd have been better off just deleting the pages. Also, <meta> redirects are not part of any standard and may be ignored entirely by the user agent, be it a browser or a search engine's spider: you must include a link to the page to which you're redirecting in the body of the HTML.

kuau
12-29-2007, 01:00 AM
I did delete the original pages and replaced them with those lame redirects. What would a proper redirect look like?

kuau
12-29-2007, 01:40 AM
Last month I moved the site to a hosting company that allows .htaccess files, so I can now change the filenames back to .html extensions, but am not sure if it is worth the effort. Does anyone there know anyhting about SEO? Would this make any difference to the page ranking? And if I changed the file extensions, what is the best way to notify the search engines of the name change? I don't want to lose what ranking already exists.

I would really appreciate some guidance in this area. Mahalo, erin

tech_support
12-29-2007, 01:49 AM
Nope. No search engine/person would actually CARE if your page is under a .html extension or .php

It might be a security risk putting your pages as .php, but "obscurity is no solution to security issues"

Twey
12-29-2007, 02:03 AM
I did delete the original pages and replaced them with those lame redirects. What would a proper redirect look like?In PHP,
<?php header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . ($url = '/location/of/new/page.html')); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="refresh" content="0;URL=<?php echo $url; ?>">
<title>Page Moved</title>
</head>
<body>
<p>This page has been moved to <a href="<?php echo $url; ?>"><?php echo $url; ?></a>.</p>
</body>
</html>
It might be a security risk putting your pages as .php, but "obscurity is no solution to security issues"It's also a performance issue, though. Probably worth it. You can do it more generally with .htaccess and mod_rewrite:
RewriteEngine on
RewriteRule .php$ .html [R]

kuau
12-29-2007, 02:03 AM
Dear tech_support:

Thanks, but I'm a bit unsure of your answer. Are you saying that there is nothing to be gained from an SEO standpoint by my changing all the pages to .html? But are you also saying I should do it because using a php extension is a security risk? How is it a security risk?

And you really lost me with "obscurity is no solution to security issues." Admittedly I am just new to forums and am still trying to figure out what some of the initials stand for, but I feel like a total moron when I need every sentence translated. Is there some forum secret lingo page I need to read? Sorry if I am a bit dense here. Thanks, erin

kuau
12-29-2007, 02:25 AM
Dear Twey: Thank you so much for showing me the proper code. I read somewhere that after a certain length of time the search engines have updated their indexes so presumably you wouldn't need the redirects after a while. Do you know if that is true and how long it would take?

If I add this to the .htaccess file:

RewriteEngine on
RewriteRule .php$ .html [R]

does that mean I just leave all the files with the php extension? And, if I do it that way, is it just as good as manually changing the file extensions? Not sure what you meant by the performance issue comment... do .html files execute faster than .php files?

Thanks a million. Sorry for all the questions but I need to understand things thoroughly (yes, I drove my teachers nuts, but was valedictorian). erin :)

Twey
12-29-2007, 02:50 AM
does that mean I just leave all the files with the php extension?No, that's for when you move all your .php files to .html to avoid the performance hit.
do .html files execute faster than .php files?Yes.

tech_support
12-29-2007, 06:13 AM
do .html files execute faster than .php files?Yes.

How is it faster?

djr33
12-29-2007, 06:26 AM
Because .html/.htm won't run through the PHP parser, whereas .php will. If you set .html to do so, then it would be just as slow. The extension does nothing except act as a label-- and the server does the rest. It just so happens that those labels are served differently.

tech_support
12-29-2007, 06:39 AM
But it's still a PHP file... just hidden in the address bar.





RewriteEngine on
RewriteRule .php$ .html [R]

Twey
12-29-2007, 07:47 AM
You're reading it the wrong way around. That redirect points all .php URLs to .html files -- for when Erin renames the files back.

kuau
12-29-2007, 10:33 AM
Dear Twey:

I just looked more closely at your rewrite of my redirect code and noticed that you used my same command line:

<meta http-equiv="refresh" content="0;URL=<?php echo $url; ?>">

Perhaps you don't realize that that line causes an immediate redirect to the URL specified, which is why I put nothing between the body tags... because it never gets that far. So your version and my version have exactly the same result. Try it and you'll see. I don't think that is what you intended. (?)

My intention was that anyone using an old bookmark with index.html would seamlessly arrive at index.php, and that is what happens. I just thought there was a more elegant method that did the redirect and at the same time informed the search engines that it was a permanent move (301). I just made that one up so figured it must be wrong.

Is there some kind of hierarchy in Apache that causes it to give preferential treatment to certain file extensions? I can understand how a pure html file might be faster because it doesn't engage the php engine, but it seems odd that the very same file would execute faster just because of the .html extension, considering it does contain php. Is it a way of tricking Apache into moving php files higher up in the hierarchy?

Mahalo, erin

Twey
12-29-2007, 10:51 AM
Perhaps you don't realize that that line causes an immediate redirect to the URL specified, which is why I put nothing between the body tags... because it never gets that far.Unless the browser doesn't support <meta> refreshes. In this case, it should be redirected via the HTTP Location header anyway, but it never hurts to have a link too. If you want to rely on the header (which is safer than relying on the <meta>) then all the HTML in that page is in fact superfluous.
My intention was that anyone using an old bookmark with index.html would seamlessly arrive at index.php, and that is what happens. I just thought there was a more elegant method that did the redirect and at the same time informed the search engines that it was a permanent move (301). I just made that one up so figured it must be wrong.There is a more elegant method, and that's exactly what I did above, using PHP and/or .htaccess, at your convenience.
Is there some kind of hierarchy in Apache that causes it to give preferential treatment to certain file extensions? I can understand how a pure html file might be faster because it doesn't engage the php engine, but it seems odd that the very same file would execute faster just because of the .html extension, considering it does contain php.If your file does actually contain PHP then the PHP won't work. I thought these were plain HTML files that you had renamed to .php in order to get consistent URLs.

I see I was wrong. The following .htaccess file should help things along:
RewriteEngine on
RewriteRule .html$ .php [R]

kuau
12-29-2007, 11:10 AM
Sorry, I thought I mentioned that I had to rename them .php to get the php to work because I couldn't use an .htaccess file on Yahoo. Literally every single file contains php includes and php variables. Most pages are dynamic & are assembled using php, variables, and data from a database. I use .htaccess on the new host to instruct the server to parse html files as php which is why I now have the option to use .html extensions.

Under these circumstances, do you change your answers? Thanks, erin

Twey
12-29-2007, 01:39 PM
I did edit. Rather than parsing .html as PHP, redirect from a .html in the URL to a .php on the file.

kuau
12-31-2007, 12:05 PM
Dear Twey:

Here is my current .htaccess file:


Options +Includes
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
ErrorDocument 404 /html/404.html

Are you saying I should change it to:


RewriteEngine on
RewriteRule .html$ .php [R]
ErrorDocument 404 /html/404.html

If I use RewriteRule, how do search engines see the files -- as .php or .html? And would I do this so that the link to the files wouldn't be broken?

Somehow I think my original question got lost in all this. I wanted to know if search engines ranked files with an .html extension higher than .php files. It was suggested that using .php was a security risk (still not sure why) and also that there was performance degradation, but that was when you thought we were comparing pure html to php files. I believe it was concluded that if the files contain php, regardless of the extension, there would be no difference in performance. That being the case, what would be the advantage of changing all the extensions from php to html? So now I'm back to my original question. Please clarify. Thanks, erin