Jump to content

Archived

This topic is now archived and is closed to further replies.

mojito

using .htaccess to parse php in .html files

Recommended Posts

Using the code in a htaccess file one can specify that any file extension be treated as if it were a php file.

I wonder why this is done, for me it makes a dependancy situation arise that if the htaccess is not there then the code is output to the browser and a security risk. Ok so we can be careful but is it a SEO thing?

do .php pages get a worse treatment from spiders?

what other considerations..

here is the content of the .htaccess for complettness-would this replicate in child folders or does this file need to be in child folders too?

[code]AddType application/x-httpd-php .html
AddType application/x-httpd-php .htm
AddType application/x-httpd-php .php3[/code]

Share this post


Link to post
Share on other sites
ratther then doing the following: [code]AddType application/x-httpd-php .html
AddType application/x-httpd-php .htm
AddType application/x-httpd-php .php3[/code]in you .htaccess do it one line like so:
[code]AddType application/x-httpd-php .html .htm .php3 .phtml[/code]
just seperate each file extension by a space!
You dont have to put .htaccess file in every folder. However you can just place it one folder and it'll effect everysingle folder that is below it. Such as the root folder (wwwroot, public_html, public_www or whatever your root folder is called).

Share this post


Link to post
Share on other sites
Keep in mind that some people are forced to do this if they don't have access to the web server configuration files.

Share this post


Link to post
Share on other sites
[quote author=mojito link=topic=89632.msg359675#msg359675 date=1143645237]
Using the code in a htaccess file one can specify that any file extension be treated as if it were a php file.
I wonder why this is done...
[/quote]
Thanks for the info, and I'll give my answer to your wonder.  We will occasionally take over a website that has already established itself with html files. If I go changing them to php files, who knows what references might get messed up (Internally, or from 3rd party links)? Now I will be able to customize those pages with my code, but not re-name them.
TecBrat.
[code]AddType application/x-httpd-php .html .htm .php3 .phtml[/code] This worked for me.

pardon a bit of keyword stuffing, but people might need help finding this thread:
parse php inside html, read php in html files, treat html like php. extensions

Share this post


Link to post
Share on other sites
Does anyone know of a situation where modifying the htaccess file (or adding one to a specific directory within a hosting account) would cause the following behavior?

I added an htaccess file consiting only of the line to a directroy where I would like .html files to be parsed for PHP:

[b]AddType application/x-httpd-php .html .htm .php3 .phtml[/b]

But now, when I navigate to that directory (without specifying a file so that it should default to index) I get prompted to open or save a file.

If I navigate specifically to the file, it is displayed in the browser, but without the PHP having been parsed.

To see what I am talking about I put up some sample files.
To see the wierd file download behavior go to:
http://www.littlegreentoaster.com/testdir/

To see the HTML file without the PHP parsed:
http://www.littlegreentoaster.com/testdir/index.html

And to validate that PHP is installed and working
http://www.littlegreentoaster.com/testdir/index2.php

Thanks in advance to anyone who can shed some light on this for me.

-adam

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.