【问题标题】:dynamic vhost configuration based on a substring of the URI基于 URI 的子字符串的动态 vhost 配置
【发布时间】:2016-08-03 10:47:15
【问题描述】:

我希望根据 URI 的子字符串执行到根目录的简单重定向。例如:

app1_{substring1}.mydomain.com 将重定向到 C:/wamp/www/substring1 app1_{substring2}.mydomain.com 将重定向到 C:/wamp/www/substring2

ServerAlias 只允许通配符...

有什么想法可以实现吗?

Apache 版本:2.2.22(WAMP 版本)

【问题讨论】:

  • Apache 版本:2.2.22

标签: apache vhosts


【解决方案1】:

试试这个:

ServerAlias *.mydomain.com
DocumentRoot C:/wamp/www

RewriteEngine on
RewriteCond %{ENV:REDIRECT_STATUS} !200
RewriteCond %{HTTP_HOST} ^app1_([a-z0-9A-Z]+)\.mydomain\.com [NC]
RewriteRule ^ /%1%{REQUEST_URI} [QSA,L]

【讨论】:

    猜你喜欢
    • 2018-10-01
    • 1970-01-01
    • 2020-05-13
    • 1970-01-01
    • 2018-06-30
    • 2018-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多