我无法将我的非 www 域版本重定向到 wwwMovedContextHandler
,它没有要重定向到的主机。
Both www.example.com
and example.com
指向我的网络服务器IP。当有人试图打开时example.com
他仍然可以通过这种方式访问我的网站。我想让他的浏览器接收 HTTP 301 重定向到www.example.com
反而。对于搜索排名很重要,搜索引擎必须知道example.com
and www.example.com
是一回事。
作为奖励,当有人尝试访问时example.com/somepath/somepage.html
我想要 HTTP 301 重定向到www.example.com/somepath/somepage.html
我该如何继续呢?我需要编写自己的处理程序还是有更简单的方法?
为了避免重定向循环,您必须定义此规则在哪些虚拟主机上起作用。
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.server.handler.MovedContextHandler">
<Set name="contextPath">/</Set>
<Set name="newContextURL">http://www.example.com</Set>
<Set name="permanent">true</Set>
<Set name="discardPathInfo">false</Set>
<Set name="discardQuery">false</Set>
<Set name="virtualHosts">
<Array type="String">
<Item>example.com</Item>
</Array>
</Set>
</Configure>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)