【问题标题】:How is it possible to run 2 Websites in 2 different subfolders on one Apache instance?如何在一个 Apache 实例上运行 2 个不同子文件夹中的 2 个网站?
【发布时间】:2021-04-14 01:36:03
【问题描述】:

我只想运行 2 个 Web 应用程序,它们都位于单独的子文件夹中。 所以子文件夹一(即主页)应该可以在:example.com 下访问。 虽然子文件夹二应该可以在 example.com/subfolder 下访问。

我知道 Apache vhosts 文件可以通过某种方式实现,但我是这个 vhost 的新手,不知道如何解决这个问题。

感谢您的帮助!

【问题讨论】:

  • httpd.apache.org/docs/2.4/en/vhosts/name-based.html 阅读有关虚拟主机的信息,然后发布您的配置以及您可能无法自行解决的具体问题。 Stackoverflow 是一个社区,您可以在其中找到确切定义的问题的解决方案,当您展示代码并展示您迄今为止为解决问题所付出的努力以及您获得的结果时。

标签: linux apache ubuntu virtualhost


【解决方案1】:

我只是让它像那样运行!考虑到安全性,这可能是个问题吗?

        <VirtualHost *:80>
            ServerName example.com
            ServerAdmin example@mail.com
            Redirect permanent / https://example.com
    
            DocumentRoot /var/www/webpage/
            <Directory /var/www/webpage/>
            </Directory>
    </VirtualHost>

**And for SSL**


<VirtualHost *:443>
    ServerAdmin example@mail.com
    ServerName example.com:443
    <IfModule mod_headers.c>
      Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
    </IfModule>
    DocumentRoot /var/www/webpage/
    <Directory /var/www/webpage/>
        Options FollowSymLinks
        AllowOverride All
    </Directory>
    <Directory /var/www/webpage>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
    Alias /subfolder /var/www/subfolder/
    <Directory /var/www/subfolder>
    Order allow,deny
    allow from all
    </Directory>


  SSLCertificateFile /etc/certs/live/**********/fullchain.pem
  SSLCertificateKeyFile /etc/certs/live/**********/privkey.pem
  Include /etc/letsencrypt/options-ssl-apache.conf

</VirtualHost>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多