Forum Moderators: coopster

Message Too Old, No Replies

parse php to htm

         

Philippe27

3:53 pm on May 9, 2009 (gmt 0)

10+ Year Member



First of all I'm a newbie and first time I'm trying to use .php. What I basically want to do is have all my pages as .htm but still be able to use .php codes in them. I know my .php code is working because when I rename my page to "test.php" it all works but it doesn't as "test.htm".

From what I understand I need to create a .htaccess file and put some text in it. I've looked around and can't seem to find anything that works. My server is netfirms and in my settings I have "htaccess: enabled" and "PHP version PHP 4".

When I go in the netfirms help all I see is this:

"Example #14:
The following example allows visitors to browse to .html pages and parse them as PHP pages (.html will be retained in the URL):

RewriteEngine On
Rewritebase /
RewriteRule ^index.htm$ index.php [L,NE]
RewriteRule ^(.*).htm $1.php [QSA,L]"

I receive the following message:
"Not Found

The requested URL /links.php was not found on this server."
so I don't think that's the right code and I didn't see that code anywhere else. At least this tells me my .htaccess file works, I just need to find the right code.

Can anyone help?
Thanks
Phil

coopster

6:18 pm on May 9, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, Philippe27.

There are a number of ways to parse files with PHP and Apache mod_rewrite is but one. If you are able to add a handler [php.net] it would be much easier. The question has been asked and answered many times here at WebmasterWorld so please take a moment to read through and try some of the answers [google.com] first.

g1smd

6:30 pm on May 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You have the choice of a using a rewrite or adding a Handler.

There's several threads in the last few weeks in the Apache forum covering this exact topic, with examples.

Philippe27

6:35 pm on May 9, 2009 (gmt 0)

10+ Year Member



Thanks,
I looked around and couldn't find anything that worked.
I tried: AddType application/x-httpd-php .htm .php
and
AddHandler application/x-httpd-php .htm .php

AddType caused problems when trying to open the page with firefox. Addhandler doesn't cause any problems but my menu doesn't show up.

With addhandler also, even if I rename my page to test.php the menu doesn't show up but if I delete the .htaccess file it'll work.

I spent hours looking for a solution and can't find anything that works. :(

Philippe27

6:37 pm on May 9, 2009 (gmt 0)

10+ Year Member



Sry I hadn't seen the Apache forum, I'll take a look

jbinbpt

6:42 pm on May 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is your .htaccess in the same directory as the html\php?

Philippe27

7:05 pm on May 9, 2009 (gmt 0)

10+ Year Member



I tried putting it straight in my www folder or in the same as my html and php pages and I get the same result with both.

I also have a page which doesn't work now but will work if I delete the .htaccess file.

My .htaccess file is this right now:
AddHandler application/x-httpd-php .htm .php

I looked around on the forums and I seem to be having the same problem as here: [webmasterworld.com...] but it doesn't seem like anyone found a solution.

[edited by: coopster at 7:12 pm (utc) on May 9, 2009]
[edit reason] no personal urls please TOS [webmasterworld.com] [/edit]

coopster

7:23 pm on May 9, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Sounds like they may not be allowing you to override that directive in your .htaccess file. You are going to need to contact your hosting provider to find out the best way to parse htm files as php.

Philippe27

7:34 pm on May 9, 2009 (gmt 0)

10+ Year Member



Thanks I just e-mailed them, I'll post when I get an answer or when I figure this out.