![](/img/trans.png)
[英]How can i check if the function based view was called from another redirect function or directly from the url?
[英]How can I redirect from one url to another using Tuckey URL rewriting?
我有两个域名,例如www.1st-domain.com
和www.2nd-domain.com
我想写一个 Tuckey URL Rewrite 规则来重定向任何去www.1st-domain.com
请求到www.2nd-domain.com
例如,如果有人点击www.1st-domain.com/sample
它应该被重定向到www.2nd-domain.com/sample
我正在尝试类似的东西:
<rule>
<name>Domain Name Check</name>
<condition name="host" operator="equal">www.1st-domain.com</condition>
<from>^(.*)</from>
<to type="redirect">http://www.2nd-domain.com$1</to>
</rule>
它不工作。 我究竟做错了什么? 请指导。
我很高兴承认自己犯了一个错误,并且重定向确实有效:
<rule>
<name>Domain Name Check</name>
<condition name="host" operator="equal">www.1st-domain.com</condition>
<from>^(.*)</from>
<to type="redirect">http://www.2nd-domain.com$1</to>
</rule>
对我不起作用; 不确定您使用的是 urlrewrite 的第 3 版还是第 4 版; 无论如何 - 查找 4.0.3 文档( https://tuckey.org/urlrewrite/manual/4.0/index.html#configuration )并稍微调整您的答案; 这就是最终对我有用的所有内容(tomcat 9.5)
<rule>
<name>Domain Name Check v2</name>
<condition type="server-name" operator="equal">^(www.1st-domain.com)$</condition>
<from>^(.*)</from>
<to type="permanent-redirect">https://www.2nd-domain.com$1</to>
</rule>
笔记; 主要更改是删除 name="host" 属性并将其替换为 type="server-name"
或 4.0 中的另一种方式这将特定于特定规则而不是适用于每个规则
<to qsappend="true"></to>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.