mod_negotiation似乎被启用,但没有扩展名的.php文件返回404

我遇到以下问题 – 移至新平台后,除非URL包含扩展名,否则PHP文件不会被find。 所以,如果/var/www包含文件problem.php ,URL http://localhost/problem.php显示正确,但是http://localhost/problem没有。 我已经尝试了以下内容:

  • 检查configuration文件中是否启用了MultiViews

     <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> 
  • 检查是否通过phpinfo()加载mod_negotiation

加载模块:core mod_log_config mod_logio mod_version prefork http_core mod_so mod_alias mod_auth_basic mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_deflate mod_dir mod_env mod_mime mod_negotiation mod_php5 mod_reqtimeout mod_rewrite mod_setenvif mod_status

  • 以防万一以上是由压力引起的幻觉,尝试加载mod_negotiation2并重新启动服务器:

     leviathan www # a2enmod negotiation Module negotiation already enabled leviathan www # service apache2 restart Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName [ OK ] leviathan www # 
  • 确信.htaccess不是通过在没有.htaccess文件的目录中testing而造成的。

但所有这一切都没有,我仍然得到404错误,我完全不明白为什么。 我究竟做错了什么? 我的平台是Linux Mint 14。

我find了解决scheme。 /etc/apache2/mods-enabled/mime.conf下行添加到/etc/apache2/mods-enabled/mime.conf

 AddType application/x-httpd-php .php .phtml .html .htm 

然后用以下命令重启apache:

 # service apache2 restart 

它完成了。 我想这是Linux Mintconfiguration中的一个错误。

来源: “在webdeveloper.com论坛上提供没有PHP文件扩展名[apache]”的页面