How to use .htaccess to parse only .html files as .php? – PHP

  php

Q(Question):

***newbie question***

Hi, I am trying to make my server (Apache) parse .html files
as .php.

I found this line of code:
ForceType application/x-httpd-php
placed it in an .htaccess file and uploaded it to the
directory I wanted it to work.
And it worked; my .html files are all parsed as .php.
But, apparently, so are my images, so they aren’t loaded
into the pages. And something else, my css file isn’t found
anymore by Netscape and Mozilla, while IE has no problem…
I’m calling my css file with @import url(all.css); in the
<style> block in the head of my .html files.

How do I make the server parse _only_ .html files as .php,
and why don’t Mozilla and Netscape find the css file? (They
did before I sent the .htaccess file)

Sincerely,


Els

Mente humana é como pára-quedas; funciona melhor aberta.

A(Answer):

On Sun, 31 Aug 2003 19:24:14 +0200, Els <el*********@PLEASEtiscali.nl.invalid>
wrote:

***newbie question***

Hi, I am trying to make my server (Apache) parse .html files
as .php.

I found this line of code:
ForceType application/x-httpd-php
placed it in an .htaccess file and uploaded it to the
directory I wanted it to work.
And it worked; my .html files are all parsed as .php.
But, apparently, so are my images, so they aren’t loaded
into the pages. And something else, my css file isn’t found
anymore by Netscape and Mozilla, while IE has no problem…
I’m calling my css file with @import url(all.css); in the
<style> block in the head of my .html files.

How do I make the server parse _only_ .html files as .php,
and why don’t Mozilla and Netscape find the css file? (They
did before I sent the .htaccess file)

Either

<Files *.html>
ForceType application/x-httpd-php
</Files>
Or just

AddType application/x-httpd-php .html


Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

A(Answer):

On Sun, 31 Aug 2003 19:24:14 +0200 in
<message-id:bi**********@reader1.tiscali.nl>
Els <el*********@PLEASEtiscali.nl.invalid> wrote:

***newbie question***

Hi, I am trying to make my server (Apache) parse .html files
as .php.

I found this line of code:
ForceType application/x-httpd-php
placed it in an .htaccess file and uploaded it to the
directory I wanted it to work.
And it worked; my .html files are all parsed as .php.
But, apparently, so are my images, so they aren’t loaded
into the pages.

Is ‘.html’ deliberately missing there?
ForceType application/x-httpd-php .html
I suspect that without, it’s forcing _everything_ to be parsed as PHP.

And something else, my css file isn’t found
anymore by Netscape and Mozilla, while IE has no problem…
I’m calling my css file with @import url(all.css); in the
<style> block in the head of my .html files.

How do I make the server parse _only_ .html files as .php,
and why don’t Mozilla and Netscape find the css file? (They
did before I sent the .htaccess file)

Sincerely,

AFAIK, @import() is for IE only.. use HTML:
<link rel="stylesheet" href="/css/foo.css" type="text/css" />
etc etc.
HTH =)

Regards,

Ian


Ian.H [Design & Development]
digiServ Network – Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.

A(Answer):

On Sun, 31 Aug 2003 18:30:16 GMT, "Ian.H [dS]" <ia*@WINDOZEdigiserv.net> wrote:

AFAIK, @import() is for IE only.. use HTML:

@import is standard CSS1, not IE specific.

http://www.w3.org/TR/REC-CSS1#the-cascade


Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

A(Answer):

Andy Hassall wrote:

On Sun, 31 Aug 2003 19:24:14 +0200, Els <el*********@PLEASEtiscali.nl.invalid>
wrote:

How do I make the server parse _only_ .html files as .php,
and why don’t Mozilla and Netscape find the css file? (They
did before I sent the .htaccess file)

Either

<Files *.html>
ForceType application/x-httpd-php
</Files>
Or just

AddType application/x-httpd-php .html

It works, thanks!
Can you recommend me any website where stuff like this is
explained in beginner mode? (just for future reference 😉 )

Els

Mente humana é como pára-quedas; funciona melhor aberta.

A(Answer):

Andy Hassall wrote:

"Ian.H [dS]" wrote:

AFAIK, @import() is for IE only.. use HTML:

@import is standard CSS1, not IE specific.

http://www.w3.org/TR/REC-CSS1#the-cascade

I used @import, so that all browsers could find the file,
except the older ones, like NN4, who would render it
completely wrong. They don’t see @import, so in there, I put
all the CSS for newer browsers. Then, I’ll make a <link
rel="stylesheet" href="/css/foo.css" type="text/css" />
which will be found by NN4, but overruled by @import for the
newer browsers. (if I make sure the @import is lower in the
<head> than the <link>..)


Els

Mente humana é como pára-quedas; funciona melhor aberta.

A(Answer):

On Mon, 01 Sep 2003 23:19:41 +0200 in
<message-id:bj**********@reader1.tiscali.nl>
Els <el*********@PLEASEtiscali.nl.invalid> wrote:

Andy Hassall wrote:

"Ian.H [dS]" wrote:

AFAIK, @import() is for IE only.. use HTML:

@import is standard CSS1, not IE specific.

http://www.w3.org/TR/REC-CSS1#the-cascade

I used @import, so that all browsers could find the file,
except the older ones, like NN4, who would render it
completely wrong. They don’t see @import, so in there, I put
all the CSS for newer browsers. Then, I’ll make a <link
rel="stylesheet" href="/css/foo.css" type="text/css" />
which will be found by NN4, but overruled by @import for the
newer browsers. (if I make sure the @import is lower in the
<head> than the <link>..)

Ahh that makes sense, and clarifies my confusion.

I was confusing (myself with) "@import() is for IE only" and "older
browsers < IE4 && NN4 etc".

I knew there was a reason and a difference in the "HTML method" and the
@import() method.. I guess I should type what I mean in future.. and
more regular coffee =)

Regards,

Ian


Ian.H [Design & Development]
digiServ Network – Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.

LEAVE A COMMENT