Manage multi robots.txt for multi subdomains

Author Message

Fabien Scantamburlo

Wednesday 30 June 2010 2:21:35 am

Hi,

I try to set a robots.txt per subdomain. But I'm unable to find how to do this. I know there's the robots.txt in the root directory, and I use it for the moment with the main domain (www).

I'm doing a mobile version and I need to set a robots.txt for this version. Does anyone know the way (.htaccess rule ?).

Cheers,

Fabien.

Jérôme Vieilledent

Wednesday 30 June 2010 3:02:11 am

Hi Fabien

We also had this issue on a multilingual site and managed to fix it :

  • Create a new "Robots.txt" content class, with at least one field dedicated to store the content of your robots.txt file
  • Instantiate your new content class in your content tree, using translations to alter the content of your robots.txt
  • Add an URL translator rule to map robots.txt to your content node
  • In your Apache Virtual Host / .htaccess file, comment the robots.txt line

Another approach would be to build a module instead of using translations (useful when your websites are totally different). Then you could store your content in a foreign table...

Hope this helps

Fabien Scantamburlo

Wednesday 30 June 2010 5:43:29 am

Hi Jérôme,

Thanks for your help. This is certainly the best way to customize robots.txt

Good job.

Cheers,

Fabien.

Luca Pezzoli

Monday 16 August 2010 9:04:01 am

Hi Jérôme,

we own a multisite installation, so every extension has a different URL.
We are trying to specify a different robots.txt file for every extension/site so we are trying to follow your instructions.

Could you be more specific in your explanation? Do we have to setup a different layout ?the physical file "robots.txt" must exist in the root of ez publish?
The optimal situation would be a pratical example.

Thanks in advance

Luca

Jérôme Vieilledent

Monday 16 August 2010 3:22:28 pm

Hi Luca

As I said, you'll need to create a dedicated content class :

  • Create a new "Robots.txt" content class, with at least one field dedicated to store the content of your robots.txt file
  • Instantiate your new content class in your content tree, using translations to alter the content of your robots.txt (yes, you will have to override the pagelayout for this content as it must be a blank layout, not HTML)
  • Add an URL wildcard rule to map robots.txt to your content node

To add a URL wildcard, go to Setup / URL Wildcards :

  • New URL wildcard : robots.txt
  • Destination : <url_of_your_content_node>
  • Leave Redirecting URL unchecked

Finally check that the following line in your Apache VHost (or .htaccess file) is commented :

RewriteRule ^/robots\.txt - [L]

Should be :

#RewriteRule ^/robots\.txt - [L]

This would do the job :)

Luca Pezzoli

Tuesday 17 August 2010 1:44:52 am

Perfect !
Rewriterule was blocking URL Wildcard.

Thank you very much Jérôme !

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 02:22:29
Script start
Timing: Jan 18 2025 02:22:29
Module start 'layout'
Timing: Jan 18 2025 02:22:29
Module start 'content'
Timing: Jan 18 2025 02:22:30
Module end 'content'
Timing: Jan 18 2025 02:22:30
Script end

Main resources:

Total runtime1.0657 sec
Peak memory usage4,096.0000 KB
Database Queries68

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0067 589.1641152.6406
Module start 'layout' 0.00670.0041 741.804739.4766
Module start 'content' 0.01081.0534 781.2813601.5000
Module end 'content' 1.06420.0014 1,382.781316.1250
Script end 1.0656  1,398.9063 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.3200160.0002
Check MTime0.00140.1295160.0001
Mysql Total
Database connection0.00080.079410.0008
Mysqli_queries0.994693.3291680.0146
Looping result0.00050.0509660.0000
Template Total1.033897.020.5169
Template load0.00210.198220.0011
Template processing1.031796.811720.5158
Template load and register function0.00010.010410.0001
states
state_id_array0.00090.086010.0009
state_identifier_array0.00140.134320.0007
Override
Cache load0.00190.1768640.0000
Sytem overhead
Fetch class attribute can translate value0.00060.058330.0002
Fetch class attribute name0.00090.082480.0001
XML
Image XML parsing0.00100.096030.0003
class_abstraction
Instantiating content class attribute0.00000.0022100.0000
General
dbfile0.00090.0881230.0000
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
13content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
4content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
3content/datatype/view/ezxmltags/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 47
 Number of unique templates used: 11

Time used to render debug report: 0.0001 secs