httpd: Don't emit robots.txt if there are no robots entries
This commit is contained in:
parent
ee082af1e0
commit
837a0c05e5
@ -208,16 +208,11 @@ let
|
|||||||
</Directory>
|
</Directory>
|
||||||
'';
|
'';
|
||||||
|
|
||||||
robotsTxt = pkgs.writeText "robots.txt" ''
|
robotsTxt =
|
||||||
${# If this is a vhost, the include the entries for the main server as well.
|
concatStringsSep "\n" (
|
||||||
if isMainServer then ""
|
# If this is a vhost, the include the entries for the main server as well.
|
||||||
else concatMapStrings (svc: svc.robotsEntries) mainSubservices}
|
(if isMainServer then [] else map (svc: svc.robotsEntries) mainSubservices)
|
||||||
${concatMapStrings (svc: svc.robotsEntries) subservices}
|
++ (map (svc: svc.robotsEntries) subservices));
|
||||||
'';
|
|
||||||
|
|
||||||
robotsConf = ''
|
|
||||||
Alias /robots.txt ${robotsTxt}
|
|
||||||
'';
|
|
||||||
|
|
||||||
in ''
|
in ''
|
||||||
ServerName ${serverInfo.canonicalName}
|
ServerName ${serverInfo.canonicalName}
|
||||||
@ -245,7 +240,9 @@ let
|
|||||||
CustomLog ${mainCfg.logDir}/access_log-${cfg.hostName} ${cfg.logFormat}
|
CustomLog ${mainCfg.logDir}/access_log-${cfg.hostName} ${cfg.logFormat}
|
||||||
'' else ""}
|
'' else ""}
|
||||||
|
|
||||||
${robotsConf}
|
${optionalString (robotsTxt != "") ''
|
||||||
|
Alias /robots.txt ${pkgs.writeText "robots.txt" robotsTxt}
|
||||||
|
''}
|
||||||
|
|
||||||
${if isMainServer || maybeDocumentRoot != null then documentRootConf else ""}
|
${if isMainServer || maybeDocumentRoot != null then documentRootConf else ""}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user