Apache's features to manipulate URL's |
---|
Often in the live of a webmaster it happens, that you want to map an old URL into a new one. The possibilities to manipulate an URL are:
Redirection The Redirect directive maps an old URL into a new one. The new URL is returned to the client which attempts to fetch it again with the new address. One disadvantage is, that the manipulated URL will be displayed in the client browser. Suppose, you want to redirect each request to another Server on the Internet, you specify the following directive in http.conf Redirect / http://www.foobar.com/ Each request to your server will be redirected to http://www.foobar.com. Rewrite Module The Apache Module mod_rewrite, is the Swiss Army Knife of URL manipulation, it is a really sophisticated module which provides a powerful way to do URL manipulations like:
Example: Map the non SSL URL http://www.foobar.com/abc to the SSL URL https://www.foobar.com/abc <VirtualHost _default_:80> Proxy Module Apache Proxy allows remote servers to be mapped into the space of the local server; the local appears to be a mirror of the remote server. The following proxy directives. In the following example the website Arkum.ch is a proxy for Akadia.ch. # ProxyPass The directive ProxyPass allows remote servers to be mapped into the space of the local server; the local server does not act as a proxy in the conventional sense, but appears to be a mirror of the remote server. Suppose the local server has address http://wibble.org/; then ProxyPass /mirror/foo/ http://foo.com/ will cause a local request for the <http://wibble.org/mirror/foo/bar> to be internally converted into a proxy request to <http://foo.com/bar>.ProxyPassReverse The directive ProxyPassReverse lets Apache adjust the URL in the Location header on HTTP redirect responses. For instance this is essential when Apache is used as a reverse proxy to avoid by-passing the reverse proxy because of HTTP redirects on the backend servers which stay behind the reverse proxy. Suppose the local server has address http://wibble.org/; then ProxyPass /mirror/foo/ http://foo.com/ Dataflow between HTTP-Client and HTTP-Server Redirect and Rewrite
One disadvantage using this approach together with another server is, that the manipulated URL is not hidden from the HTTP client, the changed URL is presented to the users. Proxy Server
There are several advantages using proxies. The new server is completely hidden for the user. The URL always points to the HTTP Proxy, the connection to the real HTTP Server is hidden. The HTTP Proxy caches the documents locally, therefore we have a performance gain. |