Q I was first introduced to Linux a couple of years ago when I started using Plesk. Over time I wanted to do more and more things that Plesk wasn't geared to handle, not at all because it's a bad product but because I have some customers with really weird and diverse requirements. What I'm doing now is setting up another server without Plesk and trying to do all the things Plesk was doing manually. I've learned loads by doing this so far but there are some things I still need to address. At the moment I'm focusing on Apache and my question is simple but I can't find an easy answer.
I'd like to be able to point a certain directory on a customer's site (call it http://domain.com/secure) to an entirely different website, which is hosted at their premises for their own internal policy reasons. The domain they are using is http://secure.domain.com). The secure.domain.com is a new host with the appropriate DNS pointing to them. All the links in their site now point to the new location but they are concerned about people who have bookmarked to old page. Obviously I can't set up secure. domain.com in my Apache config as I don't run it. The client said they could do it on their web page but don't want to take the traffic and overhead. In all honesty I don't know enough about it to discuss it with them properly.
A I'm convinced that there would be almost no extra load on Apache by having a web page doing the redirecting as you suggested, but if your customer really wants Apache to do the work at a lower level it's dead easy to do. Try adding the following into the virtual host configuration block on the server:
Redirect permanent /secure http://secure.domain.com
There are several other options for this type of redirect such as temp, seeother and gone. The Apache documentation has a good explanation of the differences between them but essentially it comes down to the HTTP code returned by Apache. With each of these, Apache on your server will give the browser the new URL and will not stay involved in the connection, which should suit your customer's policy. Your customer may also want to do some intervention for web traffic coming in from your server with this redirect to tell them that the link has changed and that they should update their bookmarks.
- Configuring Apache and NAT
- SSH, mod_rewrite and Apache
- Setting up SSL with Apache
- Block attempts to use Apache as a proxy server
- Apache 2 and PHP