Skip to main content
2 of 2
added 27 characters in body
MrWhite
  • 43.1k
  • 4
  • 50
  • 90

You can do this using mod_rewrite in the main server config (outside of any <VirtualHost> container):

RewriteEngine On

RewriteRule /check$ /var/www/html/someFile.html [L]

Any URL-path that ends with /check (including example.com/check) is internally rewritten to the file-path /var/www/html/someFile.html.

This is processed before any Alias (or AliasMatch) directives.

However, if you also have mod_rewrite directives directly in any child <VirtualHost> containers (not in <Directory> containers - which works in a different (directory) context) then you also need to enable mod_rewrite inheritance at the server/vHost level, otherwise, the mod_rewrite directives in the vHost (child) will completely override the directives in the server (parent) context (and the above rule would never be processed).

For example, in the main server config, immediately after the above RewriteEngine directive:

RewriteOptions InheritDownBefore

This will process the mod_rewrite directives in the server config before any mod_rewrite directives in any child vHost containers. (Requires Apache 2.4.8+)

Reference:

MrWhite
  • 43.1k
  • 4
  • 50
  • 90