开发者

php symfony and apache2 - inst't serving .phtml

I have a problem with apache2 settings (Ubuntu system). I would like to run symfony project on my localhost but instead of serving .phtml files, browser is trying to download files.

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

this is my file .host:

127.0.0.3 test

this is apache2/sites-available/default file

< VirtualHost 127.0.0.3:80>

ServerName test DocumentRoot "/home/m/Pr/workspace/php/test/web"

DirectoryIndex frontend_dev.php

< Directory "/home/m/Pr/workspace/php/test/web">

AllowOverride All

Allow from 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

Allow from All   </Directory>

and this is .htaccess in /test

RewriteEngine On RewriteRule ^(.*)$

/web/$1 Options +FollowSymLinks

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

and this is .htaccess in /test/web

Options +FollowSymLinks +ExecCG开发者_高级运维I

RewriteEngine On

# uncomment the following line, if you are having trouble # getting no_script_name to work RewriteBase /

# we skip all files with .something #RewriteCond %{REQUEST_URI} ..+$ #RewriteCond %{REQUEST_URI} !.html$

#RewriteRule .* - [L]

# we check if the .html version is here (caching) RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f

# no, so we redirect to our front web controller RewriteRule ^(.*)$ index.php [QSA,L]

Another problem is I think apache don't read .htaccess files.

What am i doing wrong? Maybe I forgot about something? Please, help me becouse i have no idea.


You need to declare the AddType directive in your Apache config - I'm not sure adding it to .htaccess will work.

Add this line to either /etc/apache2/mods.enabled/php.conf or /etc/apache2/httpd.conf:

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

Restart Apache and retry.


Check the Content-Type headers the server is sending for the .phtml files - chances are it's something the browser doesn't recognise.


yes I don't remember Apache to be prepared for serving phtml files out-of-the-box.

I think you need to assert Content-Type is defined to text/html for the browser to render the file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜