首页 文章

php symfony和apache2 - 不服务.phtml

提问于
浏览
0

我有apache2设置问题(Ubuntu系统) . 我想在我的localhost上运行symfony项目,但浏览器没有提供.phtml文件,而是试图下载文件 .

alt text http://www.freeimagehosting.net/uploads/ba9be708fc.gif

这是我的文件.host:

127.0.0.3测试

这是apache2 / sites-available / default文件

<VirtualHost 127.0.0.3:80> ServerName测试DocumentRoot“/ home / m / Pr / workspace / php / test / web”DirectoryIndex frontend_dev.php <Directory“/ home / m / Pr / workspace / php / test / web” > AllowOverride All

全部允许
Alias / sf / home / m / Pr / workspace / php / test / lib / vendor / symfony / data / web / sf <Directory“/ home / m / Pr / workspace / php / test / lib / vendor / symfony / data / web / sf“> AllowOverride All

允许来自所有</ Directory>
这是.htaccess in / test RewriteEngine On RewriteRule ^( . *)$ / web / $ 1选项FollowSymLinks ExecCGI AddHandler application / x-httpd-php5 .php .phtml

这是/ test / web中的.htaccess

选项FollowSymLinks ExecCGI RewriteEngine On#取消注释以下行,如果你遇到麻烦#让no_script_name工作RewriteBase /#我们跳过所有文件.something #RewriteCond% .. $ #RewriteCond%!.html $ #RewriteRule . * - [L]#我们检查.html版本是否在这里(缓存)RewriteRule ^ $ index.html [QSA] RewriteRule ^([^.])$ $ 1.html [QSA] RewriteCond% -f#no,所以我们重定向到我们的前端Web控制器RewriteRule ^( . *)$ index.php [QSA,L]

另一个问题是我认为apache不读取.htaccess文件 .

我究竟做错了什么?也许我忘了什么?请帮助我因为我不知道 .

3 回答

  • 0

    您需要在Apache配置中声明AddType指令 - 我不确定将它添加到.htaccess是否有效 .

    将此行添加到 /etc/apache2/mods.enabled/php.conf/etc/apache2/httpd.conf

    AddHandler application/x-httpd-php5 .php .phtml
    

    重启Apache并重试 .

  • 0

    检查服务器为.phtml文件发送的Content-Type标头 - 可能是浏览器无法识别的内容 .

  • 2

    是的,我不记得Apache准备好开箱即用的phtml文件 .

    我认为你需要断言Content-Type被定义为text / html以供浏览器呈现文件 .

相关问题