Home > Net >  Add deprecation header to all files in subdirectory/path using .htaccess
Add deprecation header to all files in subdirectory/path using .htaccess

Time:01-10

I have moved some stuff being deprecated to a folder called legacyFrontend

I would like to add the Deprecated header to all and any calls to those files using .htaccess

I have tried several things that are just ignored:

<FilesMatch "^legacyFrontend/.*">
    Header set Deprecation "Sat, 31 Dec 2022 23:59:59 GMT"
</FilesMatch>
<Files "legacyFrontend/">
    Header set Deprecation "Sat, 31 Dec 2022 23:59:59 GMT"
</Files>

This one just returns a 500 error

<Directory "legacyFrontend">
    Header set Deprecation "Sat, 31 Dec 2022 23:59:59 GMT"
</Directory>

CodePudding user response:

The answer is actually quite simple:

Put a separate .htaccess file in /legacyFrontend with no directives except the Header:

#deprecation header https://datatracker.ietf.org/doc/html/draft-dalal-deprecation-header-03
Header set Deprecation "Sat, 31 Dec 2022 23:59:59 GMT"
  • Related