Multiple robots.txt for subdomains in rails

后端 未结 6 2090
轻奢々
轻奢々 2021-01-31 23:21

I have a site with multiple subdomains and I want the named subdomains robots.txt to be different from the www one.

I tried to use .htaccess, but the FastCGI doesn\'t lo

6条回答
  •  天涯浪人
    2021-01-31 23:32

    If you can't configure your http server to do this before the request is sent to rails, I would just setup a 'robots' controller that renders a template like:

    def show_robot
      subdomain = # get subdomain, escape
      render :text => open('robots.#{subdomain}.txt').read, :layout => false
    end
    

    Depending on what you're trying to accomplish you could also use a single template instead of a bunch of different files.

提交回复
热议问题