我刚刚创建了虚拟主机:
<VirtualHost myvirtualhost:80>
ServerAdmin webmaster@myvirtualhost
ServerName myvirtualhost
DocumentRoot /home/myname/sites/public_html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/myname/sites/public_html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
它可以工作,但是无法读取 public_html 中的 .htacces 文件:
DirectoryIndex otherindex.php
我尝试将所有 AllowOverride 更改为 All,但出现 500 错误。我该如何修复此问题?谢谢。
答案1
mod_dir 是否已激活?
http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryindex
您还需要在 allowoverride 指令中更广泛一些,至少应该添加“AllowOverride Indexes”
http://httpd.apache.org/docs/current/fr/mod/core.html#allowoverride