【问题标题】:Chaining URL Rewrite rules in Apache 2.4在 Apache 2.4 中链接 URL 重写规则
【发布时间】:2016-03-25 11:38:05
【问题描述】:

需要一些帮助写在阿帕奇V2.4重新写入规则。

我有其在托管的Tomcat v8.0.29具有这种URL的web应用程序:

http://myapptest:8080/app

通过了mod_jk和Apache重写引擎的魔力,我已经能够清理一下只是http://myapptest。 P>

我现在已经在SSL配置Apache,我需要http://myapptesthttps://myapptest到重定向到https://myapptest.domain.com

在的httpd-ssl.conf中,我有这个虚拟主机配置,其处理重写东西:

<VirtualHost _default_:443>
  ServerName myapptest
  RewriteEngine on    
  RewriteRule   ^/$ /app [NC,PT,L]    
  DocumentRoot "c:/apache/tomcat/webapps/app"
  JkMount /* myapp          
  ErrorLog "logs/myapptest-error.log"
  CustomLog "logs/myapptest-access.log" common
  ...other stuff...
</VirtualHost>

然后,在的httpd-vhosts.conf我处理为http流量重定向端口80上 P>

<VirtualHost myapptest:80> 
    ServerName myapptest
    Redirect      /   https://myapptest.domain.com/
</VirtualHost>

在最后一块,我缺少的是如何处理重定向为https://myapptest? P>

如果有更好的,更清洁的方式来处理这个我到非常开放的,因为我不是这东西的专家。

【问题讨论】:

    标签: apache tomcat mod-rewrite url-rewriting apache2.4


    【解决方案1】:

    避免在 VirtualHost 标记中使用主机名:

    # First listed is the default for port 80
    <VirtualHost *:80> 
        ServerName myapptest.domain.com
    </VirtualHost>
    
    # Capture the short hostname and redirect to FQDN
    <VirtualHost *:80> 
        ServerName myapptest
        Redirect      /   https://myapptest.domain.com/
    </VirtualHost>
    

    【讨论】:

    • 谢谢,召集人。我没有看到 myaptest 将如何被重定向到 FQDN?
    • 当主机头是“myapptest”时,它将被发送到第二个虚拟主机。第二个虚拟主机使用 Redirect 指令将所有内容重定向到 FQDN。
    • 太棒了!如果我使用myapptest,它也会被重定向到myapptest.domain.com
    • "HTTPS://" 从我的评论中删除了
    • 对 44e 虚拟主机做同样的事情
    猜你喜欢
    • 2016-12-07
    • 1970-01-01
    • 1970-01-01
    • 2014-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多