简体   繁体   English

Apache虚拟主机多条路由

[英]Apache Virtual Host multiple routes

We have a VUE front end that is within the dist (var/www/dev/dist) folder. 我们的VUE前端位于dist(var / www / dev / dist)文件夹中。 We successfully set up when users visit dev.domain.com that it hits the dist folder. 当用户访问dev.domain.com时,它成功打到dist文件夹时,我们成功地进行了设置。 The problem we are having is with our api, which is in an api subfolder (var/www/dev/api/public). 我们遇到的问题是我们的api,它位于api子文件夹(var / www / dev / api / public)中。 What we are trying to accomplish is when the URL dev.domain.com/api is called it points to /var/www/dev/api/public and will also handle all requests appended to api (dev.domain.com/api/*). 我们要完成的工作是调用URL dev.domain.com/api时,它指向/ var / www / dev / api / public,还将处理附加到api(dev.domain.com/api/ *)。

<VirtualHost *:80>

    ServerAdmin webmaster@localhost
    Servername dev.domain.com
    ServerAlias dev.domain.com

    Alias /api /var/www/dev/api/public

    <Directory /var/www/dev/api>
            Options All
            AllowOverride All
            order allow,deny
            allow from all
    </Directory>

    DocumentRoot /var/www/dev/dist

    <Directory "/var/www/dev">
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/dev-domain.log

    # Possible values include: debug, info, notice, warn, errot, crit
    # alert, emerg.
    LogLevel warn

    Customlog ${APACHE_LOG_DIR}/dev-domain-access.log combined

</Virtualhost>

After some more researching and help from the above comment I ended up getting it to work with the following Virtual Hosts config. 经过更多研究和上述评论的帮助,我最终使它与以下虚拟主机配置一起使用。

<VirtualHost *:80>

    ServerAdmin webmaster@localhost
    Servername dev.domain.com

    DocumentRoot /var/www/dev/dist/

    <Directory "/var/www/dev/">
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

    Alias /api/ "/var/www/dev/api/public/"
    <Directory "/var/www/dev/api/public/">
            Options Indexes FollowSymLinks
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/dev-domain.log

    # Possible values include: debug, info, notice, warn, errot, crit
    # alert, emerg.
    LogLevel warn

    Customlog ${APACHE_LOG_DIR}/dev-domain-access.log combined

</Virtualhost>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM