Dynamic Virtual Host with Dynamic Alias

百般思念 提交于 2019-12-24 00:24:01

问题


I am using DNSMasq for this setup. I am having issues with Alias, as it does not work at all for dynamic virtual hosts. And there's no such a thing as VirtualAlias in Apache documentation.

I am trying to setup my new environment just like I did before for .dev tld, but I am having issues, because it require more configuration.

Here's fully functional .dev Virtual Document.

<VirtualHost *:80>
    ServerAlias *.dev
    UseCanonicalName Off
    VirtualDocumentRoot "/Users/nn/Sites/%1"
</VirtualHost>

Here's fully functional configuration for single project in the new environment that I am trying to setup for all projects with VirtualDocumentRoot.

<VirtualHost *:80>
    DocumentRoot "/Users/nn/Sites/BaseApp/app"
    ServerName base.app

    Alias /scripts "/Users/nn/Sites/BaseApp/.tmp/scripts"
    Alias /styles "/Users/nn/Sites/BaseApp/.tmp/styles"

    <Directory "/Users/nn/Sites/BaseApp/.tmp">
        Options FollowSymLinks Multiviews
        Order allow,deny
        Allow from all
        Require all granted

        ErrorDocument 403 /403.php
        ErrorDocument 404 /404.php
        ErrorDocument 500 /500.php
    </Directory>
</VirtualHost> 

And here's the attempt to recreate it for all projects that may use new environment. (the one that I need help with)

<VirtualHost *:80>
    ServerAlias *.app
    UseCanonicalName Off
    VirtualDocumentRoot "/Users/nn/Sites/%1/app"

    Alias /scripts "/Users/nn/Sites/%1/.tmp/scripts"
    Alias /styles "/Users/nn/Sites/%1/.tmp/styles"

    <Directory "/Users/nn/Sites/%1/.tmp">
        Options FollowSymLinks Multiviews
        Order allow,deny
        Allow from all
        Require all granted

        ErrorDocument 403 /403.php
        ErrorDocument 404 /404.php
        ErrorDocument 500 /500.php
    </Directory>
</VirtualHost>

It is accessible, but it searches for scripts and styles in the app folder, so surely Alias is not working. Any tips, I am clueless?


回答1:


After a very long research of 3 days and this question that nobody gave answer to, I figured following:

  • Alias - Does not work for VirtualDocumentRoot but DocumentRoot only.
  • AliasMatch - Does not work for VirtualDocumentRoot but DocumentRoot only.

Hence these two (Alias and AliasMatch) are not available for use when creating dynamic hosts.

I will update this answer if this gets resolved somehow with mode_rewrite as this seem like the only solution. Hopefully Apache creates:

  • VirtualAlias
  • VirtualAliasMatch

Someday in near future...



来源:https://stackoverflow.com/questions/34926601/dynamic-virtual-host-with-dynamic-alias

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!