Renaming *.html to *.php
Moderator: General Moderators
Renaming *.html to *.php
Reviewing PHP reveals such code is always wrapped inside a pair of tags. Does this mean a wholesale renaming of all of my HTML files to PHP will work and allow me to incrementally add PHP functions as needed?
So given a standard HTML document, then I can use PHP to manage ads more effectively as new ones come to be available.
I have a simple ad-rotator now in PHP so leveraging the code snippet into a HTML code base would be nirvana.
So given a standard HTML document, then I can use PHP to manage ads more effectively as new ones come to be available.
I have a simple ad-rotator now in PHP so leveraging the code snippet into a HTML code base would be nirvana.
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
Re: Renaming *.html to *.php
Not spam, wanted to learn how to use PHP better.
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
Re: Renaming *.html to *.php
And how is that?panic! wrote:spam.
PHP files are a subset of HTML files. Almost all HTML files can be PHP files, PHP files can't generally be HTML files.
The "almost" is because of the
Code: Select all
<?xml version="1.0" encoding="utf-8"?>Re: Renaming *.html to *.php
Hmm.. I can see where panic! is coming from. There are a whole lot of links in your sig. But I don't think this is spam so I'm not going to take any action.
Just for the record, if you're hoping those links will help your search engine position ... Googlebot doesn't see anyone's signature so they won't be helping at all.
Just for the record, if you're hoping those links will help your search engine position ... Googlebot doesn't see anyone's signature so they won't be helping at all.
Re: Renaming *.html to *.php
OK in all of my pages at present, I am using XHTML transitional as some of the ads I have now are using iframes, others are IMG others are javascript, etc. So I have a real mixed bag of code, and was hoping that Apache can figure out how to paste in an ad rotator widget so I an change ads randomly to make the sites a tad more dynamic.
I am new to PHP so forgive my ignorance, one I get a better grip on it I will be able function better and get the ball rolling to a more generally well design system.
Once the ads are finished, I was looking at installing some stock quotes and was hoping a PHP widget was available for the econ site.
This forum seemed to have some potential so hence I wanted to see if a pure XHTML can be renamed and then add code when needed. I am new to Linux and Apache, coming from a Windows platform.
As for the Google bot, there is also MSN, Yahoo etc. All junk. Curiously though my use of phpBB3 has a screen that shows who actually comes to visit my forums so it begs the question as to what does it really do?
Here are my document headers that I use now.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml" lang="en_us">
I am new to PHP so forgive my ignorance, one I get a better grip on it I will be able function better and get the ball rolling to a more generally well design system.
Once the ads are finished, I was looking at installing some stock quotes and was hoping a PHP widget was available for the econ site.
This forum seemed to have some potential so hence I wanted to see if a pure XHTML can be renamed and then add code when needed. I am new to Linux and Apache, coming from a Windows platform.
As for the Google bot, there is also MSN, Yahoo etc. All junk. Curiously though my use of phpBB3 has a screen that shows who actually comes to visit my forums so it begs the question as to what does it really do?
Here are my document headers that I use now.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml" lang="en_us">
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
Re: Renaming *.html to *.php
Just change the extensions. Although, in theory, you could set up Apache to process .html files as well as .php files (this method is kludgy, so don't do it unless you have to).
Re: Renaming *.html to *.php
Thanks, I will try that out and see how long it lasts before I come back here.
PHP seems to have some potential so I am slowly learning how to use it.
PHP seems to have some potential so I am slowly learning how to use it.
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: Renaming *.html to *.php
This is insanely simple...
1.) Do not rename your file extensions from HTML to PHP. This is bad for SEO.
2.) To execute PHP on HTML files do the following...
.htaccess
AddType application/x-httpd-php .txt .html
3.) You will have to echo the XML declaration...
1.) Do not rename your file extensions from HTML to PHP. This is bad for SEO.
2.) To execute PHP on HTML files do the following...
.htaccess
AddType application/x-httpd-php .txt .html
3.) You will have to echo the XML declaration...
Code: Select all
<?php
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
Re: Renaming *.html to *.php
You should be careful doing that. All the .txt and .html files will have to be parsed by PHP. If you have static files that don't contain any code they'll take a lot more resources on the server to be sent to the user. On an extremely busy website that's a very bad thing.JAB Creations wrote:2.) To execute PHP on HTML files do the following...
.htaccess
AddType application/x-httpd-php .txt .html
Re: Renaming *.html to *.php
Like I said, it's a kludgy way of doing something that could easily be done in much more professional a manner.
Re: Renaming *.html to *.php
What would you suggest? I could create a new *.pho and redirect the *.html easy enough. That would keep broken links at bay.
The whole idea behind my question is to better display ads and with LAMP that means PHP gets the job.
<?php
$fcontents = join ('', file ('banner_ads.txt'));
$s_con = split("~",$fcontents);
$banner_no = rand(0,(count($s_con)-1));
echo $s_con[$banner_no];
?>
In the banner-ads.txt file, put an ad on each line, and separate them with the ~ on a new line by itself. You can wrap the code in a <div> and apply any CSS style you need such as centering the ad etc.
This code can handle zillions of ads. Short, and exactly what I wanted to install.
Later when I get more skilled I wanted to move the text file to MySQL and pull ads from the database. But that is another project.
The goal with this code is to have a random ad on document footers. This code does that easily.
The whole idea behind my question is to better display ads and with LAMP that means PHP gets the job.
<?php
$fcontents = join ('', file ('banner_ads.txt'));
$s_con = split("~",$fcontents);
$banner_no = rand(0,(count($s_con)-1));
echo $s_con[$banner_no];
?>
In the banner-ads.txt file, put an ad on each line, and separate them with the ~ on a new line by itself. You can wrap the code in a <div> and apply any CSS style you need such as centering the ad etc.
This code can handle zillions of ads. Short, and exactly what I wanted to install.
Later when I get more skilled I wanted to move the text file to MySQL and pull ads from the database. But that is another project.
The goal with this code is to have a random ad on document footers. This code does that easily.
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
Re: Renaming *.html to *.php
I wasn't saying what you were doing was kludgy... I was just saying that setting Apache to process .html files as PHP isn't ideal.
Re: Renaming *.html to *.php
Well I am influenced unduly by phpBB as a platform with a lot of potential. So I speculated that PHP would be adequate to post ads in my content. All the better to temp users.
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
My site is powered by LAMP
Re: Renaming *.html to *.php
There's a bunch of crap in this topic, LOL. Well not necessarily crap, but just beating around the bush.
Just rename your .html extensions to .php extensions and you can put php code in any of them.
Simple.
Don't worry about the .htaccess part, or search engine ranking.
I've had fairly busy web sites (upwards of 200,000 page loads per day) on a pretty normal server and server load never became a problem. I've also had .php pages rank well (and yes, in google).
Keep it simple.
Just rename your .html extensions to .php extensions and you can put php code in any of them.
I've had fairly busy web sites (upwards of 200,000 page loads per day) on a pretty normal server and server load never became a problem. I've also had .php pages rank well (and yes, in google).
Keep it simple.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.