Forum Moderators: phranque

Message Too Old, No Replies

Help with .html to .php

htaccess, php and seo......

         

big_jimmi

12:11 pm on Jun 25, 2007 (gmt 0)

10+ Year Member



Hi folks

I hope this is the right place to post, I've read other posts relating to parts of my questions but I needed to double check everything. Hopefully someone can help!

I have a high traffic site which uses php to process secure forms and customer data. the index page is .html with no php (php only present in form pages) but I need to start capturing referrer info (which I can do with http referrer). My problem being I have over 15000 inbound links pointing to my home page either directly (www.abc.com/index.com) or indirectly (www.abc.com). Having recently made 3rd on the first page of google and yahho for our main keyword Im reluctant to change the file to .php incase it damages our seo....

Doesn anyone have any advise on the best way to go about this or any previous experience of search engines behavior when your change file extensions?

many thanks in advance

Revelation

12:57 pm on Jun 25, 2007 (gmt 0)

10+ Year Member



file exententions shoulnd't matter
If it might you could use a rewrite rule to make the pages rewritten to .php instead of .html,

Greets
Alex

jdMorgan

3:25 pm on Jun 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To clarify, file extensions don't matter to "the Web" because any URL extension (including none) can be mapped to any file type on your server by using mod_alias or mod_rewrite. That is, you can have a URL that says http://example.com/ and map that to users/xamplecorp/public/html/index.php, and you can map http://example.com/page.html to users/xamplecorp/public/html/page.shtml, and the client will never know the difference; The Web uses URLs, the server uses filepaths, and the two can be different.

Jim

[edited by: jdMorgan at 3:25 pm (utc) on June 25, 2007]

JennyWren1977

2:24 pm on Jul 13, 2007 (gmt 0)

10+ Year Member



I'm facing a similar situation. I've just written my own little blogging tool in php, which writes a file for each blog story so I won't have to worry about URLs with a bunch of variable in them. However, I'd like each page on my site to have links to the most recent blog entries which will be retrieved from the database. Currently most of my site is .html files, but they will all need to be changed to .php. I'm not too worried about taking the Google rank hit while Google learns that my files have moved, but I am concerned that Google will "punish" me for using php. The pages won't be passing values around so URLs will just be '.php' without a bunch of garbage following. Am I ok? I think the benefit of having fresh content on my site (articles) will outweigh anything else.

Alternately, since I am the only person writing articles, I could just update the .html pages whenever I write a new article, but this makes for a much higher overhead.

Thoughts/suggestions?

jdMorgan

4:33 pm on Jul 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



JennyWren,

Welcome to WebmasterWorld!

Please research this subject before changing any URL for any reason, ever. See Cool URIs don't change [w3.org].

You do not need to change .html URLs to .php URLs. Simply tell the server to parse .html files for PHP includes, and you are done.

If at some point in the future you do decide to change all your URLs anyway, then change them to be extensionless; The Web does not care what "filetype" you use, because the Web does not use "filenames" -- It uses URLs. It is the server's job to map requested URLs to server disk files (or to scripts), so only the server cares about "filetypes."

Servers inform clients of how to handle requested resources ("files") by sending a MIME-type identifier in the "Content-Type" HTTP response header. So the "filetype" in a URL is completely meaningless.

In general, you can tell Apache to handle .html files as .php in your .htaccess file using

 AddType application/x-httpd-php .html 

if PHP is installed as a module, or
 AddHandler cgi-script html 

if PHP is installed as CGI (ask your host if you're not sure.)

Jim

JennyWren1977

7:16 am on Jul 16, 2007 (gmt 0)

10+ Year Member



Thanks for your feedback. I'm in the process of changing the names of the files ANYHOW (they weren't descriptive enough, changing them to be more SEO friendly (keywords separated by hyphens now) so now is the time to make other changes. I'm more concerned by whether or not Google cares about the extension.

jdMorgan

4:21 pm on Jul 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, well I've failed to impress upon you the fact that URLs need not be related in any way to the underlying filenames. Google does not care about "file extensions" because Google uses URLs, not filenames, and the two are not at all the same thing. A server's function is to translate URLs to filenames, and that translation is not necessarily a direct one. Modules such as mod_rewrite, and scripts which "include" files can be used to make any URL resolve to any file on the server.

By changing your URLs instead of mapping the existing URLs to new files, you will lose the ranking of those old URLs and render obsolete any incoming links and bookmarks to those URLs. Only you can decide whether this is "worth it" as compared to the small ranking gain from the keyword-in-URL factor.

Jim

g1smd

11:31 pm on Jul 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Either tell your server to parse files that end .html as if they are also PHP scripts.

OR

Set up an internal rewrite so that a request for a .html URL results in the server pulling the PHP file, without showing any change to the requested URL.