0

我在为指向相同 IP 地址和端口的多个域重写 Oracle HTTP Server 时遇到了一些困难

以下正在工作

  RewriteEngine On
  RewriteCond %{REQUEST_URI} ^/$
  RewriteRule ^(.*)$ https://sub-doamin-1/psp/UACMP/SELF_SERVICE/SA/c/NUI_FRAMEWORK.PT_LANDINGPAGE.GBL [R,L]

但是,当我尝试https://sub-doamin-2/analytic时,它会重定向到https://sub-doamin-1/psp/UACMP/SELF_SERVICE/SA/c/NUI_FRAMEWORK.PT_LANDINGPAGE.GBL

尝试了 RewriteCond ${HTTP_HOST} 方法,但没有成功。它只是重定向到 / (根)

RewriteEngine On
RewriteCond ${HTTP_HOST} sub-doamin-1$ [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ https://sub-doamin-1/psp/UACMP/SELF_SERVICE/SA/c/NUI_FRAMEWORK.PT_LANDINGPAGE.GBL [R,L]

RewriteCond ${HTTP_HOST} sub-doamin-2$ [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ https://sub-doamin-2/analytics

你能帮忙解决这个问题吗?

4

1 回答 1

0

它应该%{HTTP_HOST}代替${HTTP_HOST}

所以规则应该是:

RewriteCond %{HTTP_HOST} sub1.test.com$ [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ https://sub1.test.com/psp/UACMP/SELF_SERVICE/SA/c/NUI_FRAMEWORK.PT_LANDINGPAGE.GBL [R,L]

RewriteCond %{HTTP_HOST} sub2.test.com$ [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ https://sub2.test.com/analytics [L]

您可以在此处查看规则:https ://htaccess.madewithlove.be?share=6632e45c-a7bb-5099-ab0b-468ba1066277

对于网址https://sub1.test.comhttps://sub2.test.com

如果你在那个网站上写下你的原始规则,你会得到This test string is not supported: ${HTTP_HOST},所以这也可以帮助你下次。

于 2019-09-25T07:49:20.960 回答