Redirect URL using Mac OS X Server Lion

5,102

The best way to do this is with a redirect -- redirects basically tell the browser "you don't want this URL, you want this one instead (as opposed to an alias, which serves different files without any indication to the browser). If you want what I'd call a full redirect (i.e. http://www.myotherdomain.com/some/document.html -> http://www.mymaindomain.com/some/document.html), you need to create a second entry in the "Web Sites" list named www.myotherdomain.com, and in it create a redirect like this:

Redirect Type: Regular Expression
Redirect Path: (.*)$
Destination URL: http://www.mymaindomain.com$1
Redirect Status: Original has moved permanently

DO NOT add this redirect to the primary web site, or it'll redirect to itself in an infinite loop. If you aren't using SSL, you don't need to create additional web sites for each additional domain name, just create one and add the others (www.mythirddomain.com, www.myfourthdomain.com, etc) to its "Additional Domains" list. If you are using SSL, you'll have to create a separate entry in the web sites list so that you can give each one its own SSL certificate (and even that may not work right unless you use different IP addresses for each name -- there are inherent problems serving multiple SSL certs on a single IP address).

Share:
5,102

Related videos on Youtube

pheedsta
Author by

pheedsta

Updated on September 18, 2022

Comments

  • pheedsta
    pheedsta almost 2 years

    I have just set up a Mac Mini with OS X Lion Server to host my own website. I have registered multiple domain names, but I would like the user to be automatically redirected to my main domain name if they type in one of the others (i.e. if the user types in www.myotherdomain.com the URL will be forwarded instantly to www.mymaindomain.com). In the Web settings of Server.app, you can easily add additional domains (which works) but it does not change the URL in the browser to www.mymaindomain.com. It keeps www.myotherdomain.com whilst still displaying the correct pages.

    Does the redirects or alias options do what I want? I can't seem to work out how to use them (there seems to be no documentation that I can find).

    In Redirects, you need to enter:

    1. 'Redirect Type' (Exact Match or Regular Expression)
    2. 'Redirect Path'
    3. 'Destination URL'
    4. 'Redirect Status' (Original was permanently moved, etc)

    In Alias, you need to enter:

    1. 'Alias Type' (Exact Match or Regular Expression)
    2. 'Alias Path'
    3. 'Destination Folder'

    Any help would be great.