By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,890 Members | 1,048 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,890 IT Pros & Developers. It's quick & easy.

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

P: n/a
Els

***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.
Jul 16 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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)
Jul 16 '05 #2

P: n/a
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.
Jul 16 '05 #3

P: n/a
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)
Jul 16 '05 #4

P: n/a
Els
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.

Jul 16 '05 #5

P: n/a
Els
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.

Jul 16 '05 #6

P: n/a
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.
Jul 16 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.