Forum Moderators: open
I have done this sucessfully in the past by inserting an include() statement inside php tags and running the html page through the php interpeter. Problem is that in this case I don't think that the host will let me run those html files through the php interpeter.
I have looked around in html at some of the tags that are not sure as much and as yet havn't found a way.
Any ideas?
If your server has php installed, then yes, it should be that simple. PHP only parses what is between <?php and?>, so you could just rename your html-files to php and it would be the same.
You may need to set the default index page accordingly. On most shared servers with php installed, this may probably not be a concern.
In apache, you set the index page with DirectoryIndex.
For instance,
DirectoryIndex index.php or DirectoryIndex index.php index.html xyz.htm. For incoming links, you could use some mod_rewrite code to redirect requests for .html to .php. That's real simple;
Options +FollowSymLinks
RewriteEngine On
RewriteRule (.*)\.html $1\.php [L] Here's some reading material for you:
The apache manual [httpd.apache.org] ¦ Apache's mod_dir manual pages [httpd.apache.org] ¦ Apache's mod_rewrite-guide [httpd.apache.org] ¦ mod_rewrite manual [httpd.apache.org] ¦ PHP tutorial [w3schools.com]
(see my profile's homepage for more resources)
And be sure to visit the Apache forum [webmasterworld.com] here on WebmasterWorld, but please read up on some of it before asking stupid questions thank you. ;) (just kidding)
Eivind
I don't think you'd have to rename everything manually.
Are you in windows world? Perhaps
ren *.html *.php would do the trick? I won't take responsibility for any screw-up on that one, so be sure to test it first on something harmless. In fact, I have no idea, because it's been a while since I was using windows. Maybe it'll work, maybe not at all. When it comes to renaming the text inside the files, it should be pretty simple. In fact, this has been discussed [webmasterworld.com] earlier today.
Eivind
Start with a blank text file and paste in the following line:
AddHandler application/x-httpd-php .html
This allows you to run php scripts in files with a .html extension.
Please disregard my previous dumb question of the value of PHP.
I read up on the PHP tutorial (righthand link given by Valder) and its an eye opener!
Looks a lot like C-language, and it executes Server Side.
Code is thus invisible to browsers who "View Source"
This answers an unrelated question (sorry, off topic) of how certain PR hogs operate.
I could never understand it before.
Scraperhog links to my my site with a target UFL something like www.scraper.com/Sites.php?site#123
Sites.php interprets site#123 into my actual URL so visitors are referred my way.
I can't see code for sites.php because it is never downloaded to my machine.
Scraper probably has that php in a directory nobody else can see, not even the search engines.
Still off-topic, does anyone know of Google can see thru or get past this to pass PR? -Larry
Start with a blank text file and paste in the following line:
AddHandler application/x-httpd-php .html
Then save the file as .htaccess and upload it to the root (httpdocs) folder on your webserver.
This allows you to run php scripts in files with a .html extension.
- - -
That looks like what I need, assuming my host allows it.
One quibble: I already have an .htaccess file up to redirect mysite.net to www.mysite.net
If I send up a NEW htaccess, I will overwrite the old one.
Can somebody walk me thru, stitching the two operations together into a single .htaccess file?
Thanks - Larry
One quibble: I already have an .htaccess file up to redirect mysite.net to www.mysite.net
If I send up a NEW htaccess, I will overwrite the old one.
Can somebody walk me thru, stitching the two operations together into a single .htaccess file?
Download the .htaccess file from your web server to your computer. Open it in your text editor of choice and simply copy the code onto a new line. Save it and upload it to the server, overwriting the one that's there.
Now I gotta read up on PHP. Should be a real education.
I like the idea of adding php inline in my .html rather that changing all my filenames.
That way I can get my feet wet, without taking a big scary dive.
I would like to put my own (hidden?) visit counters on several pages instead of just one.
Maybe I can display counts discretely, but I'm real unhappy with my present offsite count service.
It's free, and I got what I paid for.
Thanks VERY much to both you and Valder. This will be a real learning experience.
(a good one I hope!) - Larry
Renaming files: I definitly do not want to rename files unless it is a last resort.
It would:
1) Require client approval.
2) CReate more complexity in the site by requiring the mod_rewrites.
3) give rise to errors in links and require the checking of all those renamed links.
There are some situations where Google will ignore the link if the name of the file requested is not the name of the file returned. I honestly don't know if mod_rewrite creates this kind of problem.
The posting by MrNoisy about using .htaccess to force html files through the php interpeter is the way to go but . . . remember the server won't allow a .htaccess to be posted. That is why I am looking for some non php method that can be accomplished with html tags (a long shot).