放在哪里的robots.txt在Tomcat 7的? [英] Where to put robots.txt in tomcat 7?

查看:2990
本文介绍了放在哪里的robots.txt在Tomcat 7的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Tomcat 7的主办我的应用程序。
我在Tomcat家庭\\ CONF使用的ROOT.xml文件\\卡塔利娜\\本地主机

 <上下文
  的docBase =C:\\ Program Files文件\\ Apache软件基金会\\ Tomcat的7.0 \\ mywebapp \\ MyApplication的
  路径=
  重载=真
/>

这是载入我的webapp的根上下文。

但现在我很困惑,在这里把的robots.txt 的sitemap.xml 文件。当我把在C:\\ Program Files文件\\ Apache软件基金会\\ Tomcat的7.0 \\ mywebapp \\ MyApplication的,它并没有显示出来。

我也试过把它放在里面的 C:\\ Program Files文件\\ Apache软件基金会\\ Tomcat的7.0 \\的webapps \\ ROOT ,以防万一。但没有任何工程。我仍然得到404没有找到。
任何人都可以请指导。

P.S。我的web应用程序运行正常。这只是我的的robots.txt 文件不可达。

修改

我的web.xml文件:

 <滤光器>
        <过滤器名称>&springSecurityFilterChain LT; /过滤器名称>
        <过滤器类和GT; org.springframework.web.filter.DelegatingFilterProxy
        < /过滤器类>
    < /滤光器>    <过滤器映射>
        <过滤器名称>&springSecurityFilterChain LT; /过滤器名称>
        < URL模式> / *< / URL模式>
    < /过滤器映射>


解决方案

应该在上下文目录

mywebapp \\为MyApplication

流向何方你将有你的WEB-INF目录,index.html的等。

更新:

根据我们讨论的所有URL由Spring MVC的DelegatingFilterProxy处理,所以你需要排除* .TXT从这个过滤器在某种程度上,可能是通过扩展的DelegatingFilterProxy和在web.xml中配置该过滤器

解决方案:我可以通过这个技巧在Spring MVC服务器的静态内容:

 < MVC:资源映射=/ robots.txt的位置=/ robots.txt的命令=0/>

救了我一吨头痛。 :)它写入其他任何人从中受益。

I'm using Tomcat 7 to host my application. I've used a ROOT.xml file under tomcat-home\conf\Catalina\localhost

<Context 
  docBase="C:\Program Files\Apache Software Foundation\Tomcat 7.0\mywebapp\MyApplication" 
  path="" 
  reloadable="true" 
/>

This is to load my webapp in the root context.

But now I'm confused as to where to put the robots.txt and sitemap.xml files. When I put in under C:\Program Files\Apache Software Foundation\Tomcat 7.0\mywebapp\MyApplication, it doesn't show up.

I've also tried placing it inside C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT , just in case. But nothing works. I'm still getting 404 not found. Can anyone please guide.

p.s. My web application runs fine. It's just that my robots.txt file is unreachable.

EDIT

My web.xml file:

    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy
        </filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

解决方案

It should be in your context directory

mywebapp\MyApplication

just where you will have your web-inf directory,index.html etc.

UPDATE:

As per our discussion all urls are handled by Spring MVC DelegatingFilterProxy , so you need to exclude *.txt from this filter somehow, may be by extending DelegatingFilterProxy and configuring that filter in web.xml

SOLUTION: I can server static content through this hack in Spring MVC:

<mvc:resources mapping="/robots.txt" location="/robots.txt" order="0"/>

Saved me a ton of headache. :) Writing it for anyone else to benefit from.

这篇关于放在哪里的robots.txt在Tomcat 7的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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