PHP in index.html, Is it possible?

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
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

PHP in index.html, Is it possible?

Post by Joe »

Hey, Recently I purchased some web space that supports PHP, ASP, mySQL, Perl etc, etc.. but my index page has to have a *.html extension. I want it so I can log users straight in if they have a cookie set which was produced by the site itself. Is it possible to do this with the index.html file?


Regards


Joe 8)
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

you can get the server to parse html files aswel as PHP files.

Ask your provider.

Mark
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

hhmmmm

Post by Joe »

HHmmm, how would i go about doing that then. Is there any sites which tell me how to do it?

Regards


Joe 8)
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Another way i thought was if i made the index.html file a redirection to index.php?
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

i cannot see any reason why the host will allow you to use PHP everywhere EXCEPT your index page, i recommend you contact your host
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

its in the apache configuration.

You can also do it in a .htaccess file by adding this line

AddType application/x-httpd-php .php .html

(i think)

Mark
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

thats exactly what i thought he meant bech but if your read closely :wink: its not, either it ain't or his explanation is incorrect
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

...

Post by Joe »

OK thanks guys. I will try some things out and if nothing works then I will be contacting my host!
User avatar
code_monkey
Forum Newbie
Posts: 16
Joined: Tue Jul 08, 2003 6:13 am
Location: UK
Contact:

Post by code_monkey »

what about using ssi's to achieve this, you could call a bit of php in to the html page as a server side include using the <!--#include virtual="file.php" --> and use it to generate whatever output you need. Normally you just need to create a .htaccess file to allow this.
penguinboy
Forum Contributor
Posts: 171
Joined: Thu Nov 07, 2002 11:25 am

Post by penguinboy »

Bech100 wrote:its in the apache configuration.

You can also do it in a .htaccess file by adding this line

AddType application/x-httpd-php .php .html

(i think)

Mark
That would any .html file to be parsed as a .php file.

Really what he needs is something like
(I never use .htaccess, but this is from httpd.conf file)

Code: Select all

DirectoryIndex index.html index.htm index.php
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

penguinboy wrote:
Bech100 wrote:its in the apache configuration.

You can also do it in a .htaccess file by adding this line

AddType application/x-httpd-php .php .html

(i think)

Mark
That would any .html file to be parsed as a .php file.

Really what he needs is something like
(I never use .htaccess, but this is from httpd.conf file)

Code: Select all

DirectoryIndex index.html index.htm index.php

would that really be so bad though? i mean, keeping it to where all htm/html files are parsed as php. it doesn't effect the html, and he may want to just use html extensions to hide the coding language he uses...
Post Reply