Expand my Community achievements bar.

SOLVED

How to open robots.txt instead of download for AEM site

Avatar

Level 3

Hi All,

 

When accessing https://ww3.rics.org/robots.txt the browser doesn't actually display the file but download it. Could you please suggest me how can I fix it?

I am accessing the robots.txt file from dispatcher caches.

 

Thanks,

Niraj.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

hi @user00181 ,

The above solution will work, but if you don't want to make changes to the configuration file, you can add a rule at your dispatcher for a specific file so that it will open in the browser instead of downloading. 

<FilesMatch "\.robots.txt$">
    Header set Content-Disposition "inline"
    Require all granted
</FilesMatch>

View solution in original post

4 Replies

Avatar

Community Advisor

Hi @user00181 ,

Your robot.txt resource file by default have jcr:data property or jcr:content/jcr:data which has an header with value as "attachment".

You need to make an entry (exclude entry to not have the Content-Disposition as attachment)

  • Apache Sling Content Disposition filter (in your publish instance) -> Clear cache, if desired and then try accessing the file. 

43263473-A7D2-4231-B7C1-E337043B81E6.png

Regards,

Santosh 

Avatar

Correct answer by
Employee Advisor

hi @user00181 ,

The above solution will work, but if you don't want to make changes to the configuration file, you can add a rule at your dispatcher for a specific file so that it will open in the browser instead of downloading. 

<FilesMatch "\.robots.txt$">
    Header set Content-Disposition "inline"
    Require all granted
</FilesMatch>

Avatar

Level 3

Hi @Anish-Sinha 

Thank you for solution,

I am new in AEM where i need to add this rule . Actually I am using AEM 6.5 version. 

There are already some rule are available for robots.txt file.

Please check this Screenshot, in this code what i need to change or add so the robots.txt fill will open.

 

user00181_0-1657097466490.png

 

Thanks,

Niraj Singh

Avatar

Level 6

I don't really have idea on dispatcher. Not sure which file I need to make this change into.