RedirectMatch
RedirectMatch regex url
Server config, virtual host, directory, .htaccess
Again,
RedirectMatch
works like
Redirect
, except that it takes a regular
expression (discussed earlier under
ScriptAliasMatch
) as its first argument.
In the Butterthlies business, sad to relate, the salespeople have been abusing their powers and perquisites, and it has been decided to teach them a lesson by hiding their beloved secrets file and sending them to the ordinary customers’ site when they try to access it. How humiliating! Easily done, though.
The Config file is httpd3.conf :
... <VirtualHost sales.butterthlies.com> ServerAdmin sales_mgr@butterthlies.com Redirect /secrets http://www.butterthlies.com DocumentRoot /usr/www/APACHE3/site.alias/htdocs/salesmen ...
The exact placing of the Redirect
doesn’t matter, as long as it is somewhere in the
<VirtualHost>
section. If you now access
http://sales.butterthlies.com/secrets, you are
shunted straight to the customers’ index
at http://www.butterthlies.com /.
It is somewhat puzzling that if the Redirect
line
fails to work because you have misspelled the URL, there may be
nothing in the error_log because the browser is
vainly trying to find it out on the Web.
An important difference between Alias
and
Redirect
is that the browser becomes aware of the
new location in a Redirect
, but not in an
Alias
, and this new location will be used as the
basis for relative hot links found in the retrieved HTML.