我想知道是否有人可以建议我如何将域指向我localhost中的目录而不是localhost的根目录?
例如在我的主机文件中:
127.0.0.1 www.domain.com
127.0.0.1/directory/ www.domain.com
或者是否有更好的方法在localhost中设置多个站点,因为我在自己的目录中设置每个站点?
任何帮助将不胜感激
由于
答案 0 :(得分:0)
您需要使用虚拟主机:
<VirtualHost *:80>
# Admin email, Server Name (domain name) and any aliases
ServerAdmin webmaster@domain1.com
ServerName domain1.com
ServerAlias www.domain1.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html
DocumentRoot /home/demo/public_html/domain1.com/public
# Custom log file locations
LogLevel warn
ErrorLog /var/log/apache2/error-mydomainname.com.log
CustomLog /var/log/apache2/access-mydomainname.com.log combined
</VirtualHost>