php5 parsing php as html

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
isign4jc
Forum Newbie
Posts: 10
Joined: Tue Jan 13, 2009 2:03 pm

php5 parsing php as html

Post by isign4jc »

I have built a number of sites using some php code within html pages. I didn't want to use the .php extension, so I've added AddType application/x-httpd-php5 .html to my .htaccess file. The thing is, I don't want this to become obsolete whenever the next version of php comes out. Is this possible? I ask because I did have it like this: AddType application/x-httpd-php .html on one site I built and as soon as the hosting company upgraded to php 5, all their pages weren't working anymore. As soon as I added the "5" to it, it worked fine. I have built alot of sites with this already and I definitely don't want to have to go into each one individually to edit the .htaccess each time their host upgrades. Is there a solution for this? Can anyone help me out?
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: php5 parsing php as html

Post by jaoudestudios »

Why would you not want to use the *.php extension?
isign4jc
Forum Newbie
Posts: 10
Joined: Tue Jan 13, 2009 2:03 pm

Re: php5 parsing php as html

Post by isign4jc »

I guess I thought it would be better for search engines or something (do you know i it has any affect on it?). I have my text pulling from a database and then being revealed on those pages using php. Will the search engines still find this text, even though it is dynamically created?
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: php5 parsing php as html

Post by Mark Baker »

isign4jc wrote:Will the search engines still find this text, even though it is dynamically created?
Search engines don't read the PHP source, but the HTML that is rendered by PHP
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: php5 parsing php as html

Post by jaoudestudios »

isign4jc wrote:I guess I thought it would be better for search engines
Like Mark Baker said, php only produces html to the browser. So to the search engine it makes no difference *.html, *.php etc...

You're creating work for yourself :wink:
isign4jc
Forum Newbie
Posts: 10
Joined: Tue Jan 13, 2009 2:03 pm

Re: php5 parsing php as html

Post by isign4jc »

So you guys think it's better to just create these pages with the .php extension because it's possible that the .htaccess code I have created could become obsolete? Making them .php would definitely take out a few steps for me when I'm creating the website.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: php5 parsing php as html

Post by jaoudestudios »

Yep, using the php extension is fine.
isign4jc
Forum Newbie
Posts: 10
Joined: Tue Jan 13, 2009 2:03 pm

Re: php5 parsing php as html

Post by isign4jc »

I plan to use the .php extension for any subsequent websites, but is it important enough that I should go back and change what I've done previously with the .html extension to .php? I'm a bit afraid of the possibility of a hosting company upgrading in the future to php 6 and then their site not showing up properly or something. I've done anywhere from 10-15 sites this way, so it would require some work to go back and make these changes, but if it prevents my fear from happening I will do it. Your thoughts?
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: php5 parsing php as html

Post by Mark Baker »

Although to be honest -- given the large number of hosting companies that insist on running PHP4 still rather than upgrading to PHP 5 -- the possibility of a hosting company upgrading in the future to php 6 is likely to become a reality long after I've retired
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: php5 parsing php as html

Post by jaoudestudios »

If what you have done works, then I wouldn't go back and change them. Especially because google has probably indexed them as *.html instead of their true extension *.php. So changing it now could have a decremental effect.
isign4jc
Forum Newbie
Posts: 10
Joined: Tue Jan 13, 2009 2:03 pm

Re: php5 parsing php as html

Post by isign4jc »

thanks for all your help!
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: php5 parsing php as html

Post by RobertGonzalez »

If you have good placement right now on links that link to .html files then you might be in a fix. In that case use a rewrite rule to catch requests to .html extensions and route them to their corresponding .php instead. In general the file extension does not have an impact on search placement. What does have an impact is when you change file extension types (say .asp to .php) and links break. Broken links have a huge impact on search placement so you never want that.

Which is all the more reason to drop the .extension altogether and just use path based urls.
Post Reply