當我去www.example.fr我得到了正確的 DocumentRoot( /var/www/example/web
),但是當我嘗試去範例.fr,它給了我預設的 DocumentRoot( /var/www/
)。
我已經嘗試了很多事情但沒有任何效果。
/etc/hosts :
51.254.122.31 example.fr
/etc/apache2/sites-enabled/example.fr.conf :
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName example.fr
ServerAlias www.example.fr
DocumentRoot /var/www/example/web/
DirectoryIndex app.php
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
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 ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
知道我做錯了什麼嗎?
答案1
您可能忘記了NameVirtualHost
指令。您也可以使用 檢查已配置的虛擬主機apachectl -S
。