NameSilo

PHP Compiler

NamecheapNamecheap
Watch

Albatross

Established Member
Impact
0
I have a site on a web provider where .htm files aren't run through the PHP compiler, so any page that uses PHP has to end in .php. I'd like to add some PHP to my site, but there are many off-site links pointing to my different pages so that renaming all my pages to .php would break a lot of stuff that's beyond my control.

When I was asking another question on an unrelated site, someone said something about making or adding to a .htaccess file without elaborating, but I don't really know what that means.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
If your host supports .htaccess and allows you to change that option via .htacess what you would do is open up a blank text file and put the following in it:

Code:
AddType application/x-httpd-php .htm .php

Then save the file as htaccess and upload it to your root directory. Once it's uploaded you'll need to rename it to .htaccess
 
0
•••
Paste the following into your very favourite text-editor, save as .htaccess and place in your home directory.
Code:
AddType application/x-httpd-php .htm
 
0
•••
Will the effects trickle down into my sub-directories or does each directory require its own .htaccess?
 
0
•••
Usually it will affect all directories as long as you put it in your root directory.
 
0
•••
I use this:

addhandler application/x-httpd-php .htm
 
0
•••
Well, the

AddType application/x-httpd-php .htm

line made my web browser (Safari) download rather than view my .htm files. I had better luck with

addhandler application/x-httpd-php .htm

in the sense that my .htm files stayed visible but didn't evaluate PHP. Though both times, renaming the file to .htaccess once uploaded made it vanish from Cyberduck's FTP screen. I had to download another client and check the 'Show Hidden Files' option to remove the .htaccess file. Either way, .htm files still don't evaluate PHP.

On a side note, I thought that in .php files, text outside the <?php ?> tags wasn't evaluated...on my server, it's being evaluated as XHTML.
 
0
•••
Your host possibly doesn't support .htaccess or just doesn't allow them things to be changed via .htaccess, or simply doesn't offer PHP. Have you checked to make sure your host actually offers PHP?

You can just upload another .htaccess file and it will overwrite the old one, and a blank .htaccess won't do any harm. That could save you from going through and using another client just to delete the file.

PHP should only be evaluated inside the PHP start and end tags. How did you conclude that your code is being evaluated as XHTML when inside the PHP start and end tags? That shouldn't have anything to do with XHTML, because that is all evaluated by your browser.
 
Last edited:
0
•••
just use htaccess/mod_rewrite...easy
 
0
•••
deadserious said:
PHP should only be evaluated inside the PHP start and end tags. How did you conclude that your code is being evaluated as XHTML when inside the PHP start and end tags? That shouldn't have anything to do with XHTML, because that is all evaluated by your browser.

I never said code inside the PHP tags was being evaluated as XHTML...rather, in .php pages, code OUTSIDE the PHP tags is evaluated as XHTML, and in .htm pages, code INSIDE the PHP tags is simply being ignored.

The solution for me here is probably to switch hosting companies, which is something I've been considering for awhile due to a number of things I'm unhappy about. I'm considering PowWeb pretty seriously.
 
0
•••
Appraise.net

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy — Zero Commission
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back