Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tomcat:如何将www子域重定向到裸域_Tomcat - Fatal编程技术网

Tomcat:如何将www子域重定向到裸域

Tomcat:如何将www子域重定向到裸域,tomcat,Tomcat,我在Tomcat服务器上遇到了一些问题:我试图将所有以裸域开始的请求重定向到以www开始的请求。 谷歌搜索和使用URLEwriteFilter指南为我提供了一些相反方向的谷歌示例(从裸域到www): 将所有恼人的www请求移动到裸域 域名检查 www.motheral-beauty.co.il ^(.*)$ http://www.maternal-beauty.co.il$1 问题是,当我刚刚删除“www”前缀时,我根本没有重定向。我请求的每个地址都返回了corespomding页面,没有任

我在Tomcat服务器上遇到了一些问题:我试图将所有以裸域开始的请求重定向到以www开始的请求。 谷歌搜索和使用URLEwriteFilter指南为我提供了一些相反方向的谷歌示例(从裸域到www):


将所有恼人的www请求移动到裸域
域名检查
www.motheral-beauty.co.il
^(.*)$
http://www.maternal-beauty.co.il$1
问题是,当我刚刚删除“www”前缀时,我根本没有重定向。我请求的每个地址都返回了corespomding页面,没有任何重定向

<rule>
    <note>
        Moves all annoying www requests to the naked domain
    </note>
    <name>Domain Name Check</name>
    <condition name="host" operator="notequal">maternal-beauty.co.il</condition>
    <from>^(.*)$</from>
    <to type="permanent-redirect">http://maternal-beauty.co.il$1</to>
</rule>

将所有恼人的www请求移动到裸域
域名检查
母性美容公司
^(.*)$
http://maternal-beauty.co.il$1
请注意,唯一的区别是我从condition元素和to元素中删除了“www”前缀。 我想不出这里有什么问题。 如果重要的话,我使用的是Tomcat 7.0.34,当然还有org.tuckey.web.filters.urlrewrite.UrlRewriteFilter

谢谢你的回复


Guy

这可能与您正在尝试做的事情无关,但您能否通过域名提供商更轻松地处理此问题?我使用过的大多数方法都允许您在通常称为控制面板或控制台的地方设置记录和转发。在您的情况下,这意味着有一个域名的www.版本的记录(所有www.版本使用给定的IP地址并显示www.域名),并将“裸域”转发到www版本

<rule>
    <note>
        Moves all annoying www requests to the naked domain
    </note>
    <name>Domain Name Check</name>
    <condition name="host" operator="notequal">maternal-beauty.co.il</condition>
    <from>^(.*)$</from>
    <to type="permanent-redirect">http://maternal-beauty.co.il$1</to>
</rule>