Refer to a websites' domain in robots.txt by a variable

by JohnDoea   Last Updated September 12, 2019 06:04 AM

I have a website (built with MediaWiki 1.33.0 CMS) which contains a robots.txt file.
In that file there is one line containing the literal domain of that site:

Sitemap: https://example.com/sitemap/sitemap-index-example.com.xml

I usually prefer to replace literal domain referrals with a variable value call that will somehow (depends on the specific case) will be changed in execution to the value which is the domain itself.

An example to a VVC would be a Bash variable substitution.


Many CMSs have a global directives file which usually contains the base address of the website:
In MediaWiki 1.33.0 this file is LocalSettings.php which contains the base address in line 32:

$wgServer = "https://example.com";

How could I call this value with a variable value call in robots.txt?
This will help me avoid confusion and malfunction if the domain of the website is changed; I wouldn't have to change the value manually there as well.



Related Questions


Updated April 18, 2015 23:01 PM

Updated December 13, 2016 08:01 AM

Updated December 01, 2018 13:04 PM

Updated June 04, 2019 13:04 PM