Current time: 05-04-2024, 10:29 PM Hello There, Guest! (LoginRegister)


Post Reply 
problem parsing html as php with .htaccess
Author Message
kilburn Offline
Development Team
*****
Dev Team

Posts: 2,182
Joined: Feb 2007
Reputation: 34
Post: #5
RE: problem parsing html as php with .htaccess
First of all, you have to determine if your server is using FastCGI or Fcgid, because the configurations differ between them.

Under fastcgi
As long as .htacces is allowed to override FileInfo settings (AllowOverride +FileInfo or AllowOverride All), you can force files with .ext1 [.ext2 [...]] extensions to be run as a php script with:
Code:
# Enable php for another extension
AddHandler php-fastcgi .ext1 .ext2

Similarly, you can...
Code:
# Disable php in this folder and it's childs (unles re-enabled by another .htaccess)
RemoveHandler .php .php5

Under fcgid
You're out of luck, as the default configuration doesn't allow you to do this (at least I've been unable to). Now, I enabled this possibility by following these steps:

1. Replace the "<IfModule mod_fcgid.c>....</IfModule>" block from the files /etc/ispcp/apache2/parts/{als,dmn,sub}_php2_entry.tpl by the following one:
Code:
<IfModule mod_fcgid.c>
        Alias /fcgi/ {STARTER_DIR}/{DMN_NAME}/
        <Directory "{STARTER_DIR}/{DMN_NAME}/">
                AllowOverride None
                SetHandler fcgid-script
                Options +ExecCGI
        </Directory>
        AddHandler php{PHP_VERSION}-script .php .php{PHP_VERSION}
        Action php{PHP_VERSION}-script /fcgi/php{PHP_VERSION}-fcgi-starter
        AddType application/x-httpd-php .php
    </IfModule>

2. Regenerate domain configurations and restart apache.

3. Insert the following in your .htaccess:
Code:
# Enable php for html-files
AddHandler php5-script .htm .html

Similarly, you can...
Code:
# Disable php in this folder and it's childs (unles re-enabled by another .htaccess)
RemoveHandler .php .php5

Using mod_rewrite
Obviously, you can also try to use mod_rewrite instead:
Code:
RewriteEngine On
RewriteRule ^(.*).html?$ $1.php [L]

And then rename all your files to .php instead of .htm(l)...

Hope this helped.
(This post was last modified: 01-21-2010 02:44 AM by kilburn.)
01-21-2010 02:36 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
RE: problem parsing html as php with .htaccess - kilburn - 01-21-2010 02:36 AM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)