The Most Active and Friendliest
Affiliate Marketing Community Online!

“Propeller”/  Direct Affiliate

htm to php - which way to go?

Dohi

New Member
affiliate
hope I'm posting it in the right topic (if not, feel free to move it and sorry).

like I said in the introduction topic, I'm in the middle of redesigning one of my websites. it's coming along nicely I guess, thanks for asking :) (considering I'm learning everything as I go along)

I know this topic has been done to death, and I've read a lot about it here and elsewhere, but I'm still not sure which way to go and I want to do it right.

I currently have about 1300(!) .htm files, and I'm pretty sure I don't want to change that. long story short: I want to have the book and movie pages' subsections (such as characters, reviews, awards, dvd infos, etc.) in separate files for each book or movie, so even though there are only about 50 books and 50 movies, with these subpages I have about 1000 files in these two folders alone. I could change this, but I considered my options (everything in one file or using tabs) and I decided not to.

anyway. I use php's include function for the menus and such (and probably will use some other php stuff, don't know yet), so I'll have to do something about .htm files, while keeping whatever little presence my site has in google's database. (not that I did anything about it, but google found even my not-so-popular site :))

as far as I can tell after a couple hours of googling (and a few more reading this forum), I have 2 (and a half) real choices: I either have to bug the guys who run the server I'm on - and thus have access to .htaccess - to enable .htm files to act like .php, or use some sort of 301 redirect or rewrite or something. I'm not sure about the advantages or drawbacks of either, so I'd like to ask you guys (the 'half' option is at the end of my post).

I don't think I have to do anything about index.htm turning into index.php, though. mysite.something.hu/ (it's a subdomain) is the same as mysite.something.hu/index.htm, but the latter never shows anywhere anyway (not even google, I'm using frames now), and since the server can handle .php files (I tried it), simply replacing index.htm with index.php when the time comes shouldn't do any harm (not even in google). hope I'm right about that.

(as a side-question: am I assuming correctly that I should link my top-of-the-page logo/banner (and the first menu item that also leads to the front page) to mysite.something.hu/ and not simply /index.php, because this would be treated separately by google?)

in theory, the former solution (AddType application/x-httpd-php .htm) shouldn't have any drawbacks: I keep using .htm files (and the same filenames and directory structure in almost every case - if it isn't broken, don't fix it :)), php commands get executed, google keeps googling my .htm files, and all the visitors will notice is the blinding new features and such, so everyone's happy :)

the latter, however, seems to be a bit trickier, more dangerous even (at least to me), and I'm not sure if it's worth the trouble at all. (well, actually in both cases it only involves adding a couple of lines to .htaccess, and it wouldn't even be done by me, but still...)

I think I've found what I need to make the 301 redirect happen, but I've found slightly different pieces of code and I can't even tell the difference between the following two (not being a programmer or very smart :)) though someone mentioned elsewhere that all the first one did for him was duplicating every .htm file with a .php extension, and that I _don't _ want.

RewriteEngine on
RewriteBase /
RewriteRule (.*).htm$ /$1.php

RewriteEngine On
RewriteRule ^(.*)\.htm$ $1.php

btw, my understanding is that since my site's a subdomain, I could have my own .htaccess file (after asking for permission from the server admins, of course) in which I'd only include the one addtype line or a 301 redirect. couple of stupid questions about this: would this even work? would it 'inherit' the stuff from the main domain's .htaccess, such as security measures, and so on? (I'm afraid it wouldn't, or that's how I interpreted the last paragraph in melkior's htaccess tutorial - so what can be done about security then?) and if I choose 301 redirect, could I remove my .htaccess file after a while, when it achieved what it was supposed to, that is, google learns about my php files and forgets that I ever had any .htm files online?

or, there's an alternate 'half' solution to all of the above: I'd upload my php stuff, delete the tons of .htm subpages that were linked with javascript (to produce pop-ups) and thus were/are rarely found by google anyway (but it _did_ find some of them, strange as it seemed to me). that'd take care of about 90% of the files. I'd keep the main pages online with a meta redirect so that clicking on google's .htm results wouldn't end in 404 errors, but would load the desired page's new version until google 'finds' the .php versions. and I'd also add a robots.txt to my site that'd disallow every .htm file to be touched.

this should - eventually, hopefully - result in my .htm's not showing up in google anymore, while my php's do, and I don't think I'd lose any google 'presence' (though I'm not entirely sure). and when this happens, I can add a google custom search to my site (which is already done, but it doesn't have a point yet, since it'll only finds .htm's until the new site's up and been crawled).

so, any thoughts, ideas?

thanks and sorry for the long post and the huge number of - probably stupid - questions!

edit: one more thing that just dawned on me: asking the admins to do the 301 redirect while only the .htm based site is online would be stupid (though it should be done as soon as possible after the php site is online), but would the addtype thing screw up the current website as well?
 
Last edited by a moderator:
Well, if i were you i won't use .htaccess file to redirect htm extension to php, but to make htm parse as htm. Depending your server setting it can be arranged by AddType application/x-httpd-php .htm, or AddHandler application/x-httpd-php .htm.
And yes, the domain-com/index.php is treated as different content because the index file of a given folder can be different from the index.anytypeoffileextension controlled by .htaccess.
 
thanks for the fast reply, zoli!

what would happen to my current (.htm based) site if the addtype (or addhandler) thing were to be taken care of as soon as possible, well before the new site's launch?

I'm guessing nothing would change, but it's very important to be sure, because the current site should be online till september, but without this addtype thing I can't launch the new one with .htm extensions, and I'm not sure how long it takes the admins to get around to changing the .htaccess file (and they certainly won't be around in the middle of the night, when I plan to do the update :)).

thanks!
 
If you make htm file extension parsed as php no 404 error will be served to Googlebot, so as i said this is what i would do.
 
I see. thanks again. I'll be sure to mail my admins soon about this and hope they're willing to co-operate :)
 
Bagi is spot on. It's the only way to go that would leave your present SE performace intact. If your Host cannot or will not facilitate this, change your host to one that does. Good performance Cpanel hosting is now cheap enough to not be too much of a factor. The only point to be careful of is the combination Geo-location of server, Domain suffix and target audience countrywise.
 
MI
Back