如果我浏览: http://example.com/ : http://example.com/或http://example.com/index.php我得到所需的页面,但如果我浏览http://example.com/index (或没有扩展名的任何页面)它会显示我的CSS或有时JS在普通的txt文件视图。 Apache 2.4.7 Ubuntu 14.04 LTS。 任何想法为什么这种行为正在进行? 我有一个很好的search – 没有运气。
我添加了AddType application/x-httpd-php .php .html到mimetypes,但是它似乎没有影响这个问题。
inheritance人我的default.conf:
<VirtualHost *:80> ServerAdmin [email protected] ServerName example.com ServerAlias www.example.com DocumentRoot /srv/www/html <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /srv/www/html> AddType audio/ogg .oga AddType video/ogg .ogv AddType application/ogg .ogg AddType audio/mpeg .mp3 AddType application/x-httpd-php .php .html Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> .. rest is just log and pw protect etc
更改apache.conf的部分:
<Directory /> ExpiresActive On ExpiresDefault "access plus 12 hours" ExpiresByType application/javascript "access plus 10 months" ExpiresByType image/jpg "access plus 10 months" ExpiresByType image/jpeg "access plus 10 months" ExpiresByType image/gif "access plus 10 months" ExpiresByType image/png "access plus 10 months" ExpiresByType text/css "access plus 10 monthss" ExpiresByType image/x-icon "access plus 10 months" FileETag MTime Size </Directory>
以下是已安装模块的列表:
core_module (static) so_module (static) watchdog_module (static) http_module (static) log_config_module (static) logio_module (static) version_module (static) unixd_module (static) access_compat_module (shared) alias_module (shared) auth_basic_module (shared) authn_core_module (shared) authn_file_module (shared) authz_core_module (shared) authz_groupfile_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) cache_module (shared) cache_disk_module (shared) cgi_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) expires_module (shared) filter_module (shared) headers_module (shared) lbmethod_byrequests_module (shared) mime_module (shared) mpm_prefork_module (shared) negotiation_module (shared) pagespeed_module (shared) php5_module (shared) proxy_module (shared) proxy_balancer_module (shared) proxy_http_module (shared) reqtimeout_module (shared) rewrite_module (shared) setenvif_module (shared) slotmem_shm_module (shared) status_module (shared)
看起来像是vhost.conf或apache.conf文件中的Multiviews选项。
<Directory /srv/www/mysite/html/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory>
删除MultiViews修复了这个问题。
虽然为什么Apache会selectindex.js而不是index.php,我不知道。