UrlRewriteFilter:www和https重定向 [英] UrlRewriteFilter: www and https redirect

查看:98
本文介绍了UrlRewriteFilter:www和https重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Tuckey UrlRewriteFilter强制用户进入我的网站的"www"和"https"版本.我的意思是接下来的3个URL必须重定向到https://www.myweb.com

I am using Tuckey UrlRewriteFilter to force users to go to the 'www' and 'https' version of my web. I mean next 3 URLs must redirect to https://www.myweb.com

  • http://www.myweb.com
  • http://myweb.com
  • https://myweb.com
  • http://www.myweb.com
  • http://myweb.com
  • https://myweb.com

问题出在最后一个问题上,我找不到将"www"替换为"https"的解决方案.我有一个下一个规则,可以使2个第一种情况正常工作:

The problem comes with the last one, I cannot find the solution to put 'www' for 'https'. I have the next rule that makes 2 first cases work without problems:

  <rule>
    <name>Domain Name Check</name>
    <condition name="host" operator="equal">myweb.com$</condition>
    <condition type="scheme" operator="equal">^http$</condition>
    <from>^(.*)$</from>
    <to type="permanent-redirect">https://www.myweb.com$1</to>
  </rule>

这当然不适用于第三种情况.如果我对第三种情况尝试类似的规则,如下所示,那么它也不起作用(我也不知道为什么):

This one of course does not apply for the third case. If I try a similar rule for the third case like the following, it doesn't work either (I don't know why):

  <rule>
    <name>Domain Name Check</name>
    <condition name="host" operator="equal">myweb.com$</condition>
    <condition type="scheme" operator="equal">^https$</condition>
    <from>^(.*)$</from>
    <to type="permanent-redirect">https://www.myweb.com$1</to>
  </rule>

能否请您帮我弄清楚第三种情况的规则?

Could you please help me to figure out the rule for the third case?

谢谢.

推荐答案

问题不是过滤器,而是我的证书.我为www.myweb.com颁发了证书,但没有为myweb.com颁发证书,因此https://myweb.com请求没有到达我的服务器,浏览器检测到该证书无效并阻止了该过程.

The problem was not the filter but my certificate. I issued my certificate for www.myweb.com but not for myweb.com so https://myweb.com request didn't reach my server, the browser detected the certificate was not valid and blocked the process.

我刚刚为https://myweb.com颁发了证书,并修改了我的Tuckey规则,如下所示.现在,https://www.myweb.com是用户只能使用的URL.

I just issued my certificate for https://myweb.com and modified my Tuckey rule as you can see below. Now https://www.myweb.com is the only URL users can use.

  <rule> 
    <name>Domain Name Check</name>
    <condition type="request-url" operator="equal">(^http://myweb.com|^http://www.myweb.com|^https://myweb.com)</condition>
    <from>^(.*)$</from>
    <to type="redirect">https://www.myweb.com$1</to>
  </rule>

这篇关于UrlRewriteFilter:www和https重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆