如何使通过Apache一个.phtml作为文件 [英] How to render a .phtml file through apache

查看:144
本文介绍了如何使通过Apache一个.phtml作为文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想渲染通过Apache一个.phtml作为文件,但是当我尝试,它呈现的页面为文本,而不是HTML。

I want to render a .phtml file through Apache, however when I try, it renders the page as text and not as html.

在我的虚拟主机配置中,如果我试图渲染的index.php,它执行正常。但是,当我改变的DirectoryIndex到index.phtml并尽量使index.phtml present它只是呈现文本的公共目录。

In my vhost configuration, if I try to render an index.php, it executes properly. But when I change the DirectoryIndex to index.phtml and try to render the index.phtml present in the public directory it just renders text.

虚拟主机配置是:      code     服务器名parminder.com     的DocumentRootC:/工作区/ parminder_local_net /公     错误日志日志/ parmindercom.log     
            选择指标的FollowSymLinks             设置AllowOverride所有             订购允许,拒绝             所有允许          DirectoryIndex的index.phtml *

The vhost Config is: code ServerName parminder.com DocumentRoot "C:/workspace/parminder_local_net/public" ErrorLog logs/parmindercom.log
Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all DirectoryIndex index.phtml *

还有什么我需要配置这个工作?我需要使用的.htaccess? 什么是基本概念?

What else do I need to configure for this to work? Do I need to use .htaccess? What is the basic concept?

推荐答案

您需要配置Apache,因此它知道你想.phtml作为文件被视为PHP。请参见 PHP的安装指南

You need to configure Apache so it knows that you want .phtml files to be treated as PHP. See step 8 of the PHP install guide.

<FilesMatch "\.ph(p[2-6]?|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>

...但.phtml作为是用于PHP 2.你或许应该审核这些文件的扩展名,使其达到现代化的PHP编码实践,并重新命名他们跟随当前的约定。

... but .phtml is the file extension used for PHP 2. You should probably audit them, bring them up to modern PHP coding practises and rename them to follow current conventions.

这篇关于如何使通过Apache一个.phtml作为文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆