如何使用子目录与新域指向相同的服务器作为一个不同的域与Apache [已关闭]

tpgth1q7  于 2023-02-09  发布在  Apache
关注(0)|答案(1)|浏览(168)

此问题似乎与a specific programming problem, a software algorithm, or software tools primarily used by programmers无关。如果您认为此问题与another Stack Exchange site的主题有关,您可以留下评论,说明在何处可以回答此问题。
昨天关门了。
Improve this question
我希望域"www.example.com,www.example.com"将用户带到/var/www/html/,域"www.example.com,www.example.com"将用户带到/var/www/html/example-2/ example-1.com , www.example-1.com " to take users to /var/www/html/ and the domain, " example-2.com , www.example-2.com " to take users to /var/www/html/example-2/
每个域的根目录不同。
我以前做过,但是不记得怎么做了,我想是用httpd.conf加虚拟主机什么的,然后重启服务器。
有什么建议吗?
我试着在谷歌上搜索,但我没有找到一个简单的答案...

djp7away

djp7away1#

你可以这样做,我给你分享Apache documentation,你需要使用两个vhost,一个vhost对应一个文件,我更喜欢,你不需要修改httpd.conf。

# First file
<VirtualHost *:80>

  ServerName     www.example-1.com
  ServerAlias    example-1.com

  DocumentRoot   /var/www/html/
  <Directory /var/www/html/>
    AllowOverride None
    Require all granted
  </Directory>
</VirtualHost>

# Second file
<VirtualHost *:80>

  ServerName     www.example-2.com
  ServerAlias    example-2.com

  DocumentRoot   /var/www/html/example-2/
  <Directory /var/www/html/example-2/>
    AllowOverride None
    Require all granted
  </Directory>
</VirtualHost>

希望这对你有帮助

相关问题