2016-07-04 120 views
0

我目前有一個使用SSI的html頁面。我現在需要添加一些PHP代碼到該頁面:在Apache服務器上的php和SSI衝突

<?php 
    session_start(); 
    $_SESSION["animal"] = "dog"; 
?> 
<!DOCTYPE html> 
<html> 

我可以成功實現SSI或PHP,但不能同時實現。我相信這個問題是在這裏,在我的httpd.conf文件:

AddType text/html .html 
    AddOutputFilter INCLUDES .html 

    AddHandler application/x-httpd-php .php 
    AddType application/x-httpd-php .php .html 
    LoadModule php5_module "C:/php5/php5apache2_4.dll" 
    PHPIniDir "c:/php5" 

</IfModule> 

我有2條不同的線將AddType,並不斷將AddType是第二上市,是工作的一個。有沒有辦法讓AddType同時工作?

謝謝!

+0

如果您已正確安裝證書ssl,是否將其保存在證書管理器工具中? http://superuser.com/questions/713810/install-ssl-certificate-from-an-untrusted-website-into-the-certificates-snap-in –

+0

我會在明天檢查,但如果是的話,這將如何幫助解決我的問題?下一步會是什麼? –

回答

0

使用FilesMatchSetHandler並把這個.htaccess而不是httpd.conf

# Enable server side includes 
Options +Includes 

# Handle files ending in .php, .shtml, and .html using the PHP interpreter: 

<FilesMatch "\.(php|shtml|html)$"> 
    SetHandler application/x-httpd-php 
</FilesMatch> 

# Filter .php, .shtml and .html files through mod_include first 
AddOutputFilter INCLUDES .php .shtml .html 

和測試都在同一個頁面:

<!DOCTYPE html> 

<head> 
<title>PHP/SSI Test Page</title>  
</head> 

<body> 

<!--#echo var="DATE_LOCAL" --> 
<? echo "Last Updated: ".date("F jS Y", 
getlastmod()); ?> 

</body> 
</html> 

參考