I have 5 virtual hosts in httpd.conf. All of them have the configuration below except for one.

<Location />
    Order Deny,Allow
    Deny from all

I think it would be better to tell all virtual hosts to have this except for one. Currently, I am telling each virtual host one by one to have this. Is there a wild card method to apply this setting to all virtual hosts and then remove this stanza from one of the virtual hosts in httpd.conf?


Yes, you can define your global <Location> in the main apache configuration, before your <Virtualhost> directives and then override it with the same <Location> inside one of your virtualhosts.

<Location />
    # some directives

<Virtualhost *:80>
    <Location />
        # some other directives

See https://httpd.apache.org/docs/current/mod/core.html#location and https://httpd.apache.org/docs/current/mod/directive-dict.html#Context for more - the reason this works is because <Location> is valid in both the "server config" and "virtual host" contexts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy