user1657533
user1657533

Reputation: 31

Apache: how to use substitute on error pages?

I have set up a reverse proxy and I'm using mod_filter for text substitutions i.e.:

FilterDeclare MYFILTER FilterProvider MYFILTER SUBSTITUTE "%{CONTENT_TYPE} =~ m|^text/html|"

FilterChain MYFILTER Substitute "s|some text|test|i"

This works fine on pages with status code 200 but doesn't seem to run on error pages (404, 503, etc).

Any ideas what I might be missing?

Upvotes: 3

Views: 1782

Answers (1)

mikhail krughkov
mikhail krughkov

Reputation: 63

The docs say filter normally applies to response status 200. To enable it to all statuses we set environment variable filter-errordocs. See also mod_filter: Why does a SUBSTITUTE not work for certain URLs?

# filter-errordocs: http://httpd.apache.org/docs/2.4/mod/mod_filter.html
# https://stackoverflow.com/questions/18163195/mod-filter-why-does-a-substitute-not-work-for-certain-urls
SetEnv filter-errordocs
FilterDeclare MYFILTER FilterProvider MYFILTER SUBSTITUTE "%{CONTENT_TYPE} =~ m|^text/html|"
FilterChain MYFILTER Substitute "s|some text|test|i"

Upvotes: 6

Related Questions