Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Just a quick beginner's question here. I have a webapp located at domainxyz.com, and it generates short URLs for long posts automatically - so rather than visit domainxyz.com/reallylongpostnamehere I can just type domainxyz.com/a5c and be taken there automatically.

However, I've bought a shorter domain name - short.com - and I want to be able to visit short.com/a5c and be redirected (or forwarded) to domainxyz.com/a5c. Or short.com/7f0 --> domainxyz.com/7f0. This way, although it seems a tad illogical it saves me setting up another hosting account on short.com to deal with the URL shortening.

Is this possible? I realise you can forward domains, but, can you forward domains AND forward the URL segments?



share|improve this question

2 Answers 2

up vote 3 down vote accepted

You can set up an A record for short.com to point the same address as is given in the A record for domainxyz.com so your users trying to visit http://short.com/a5c will actually send their requests to the same server as domainxyz.com though it will appear as short.com in their address bar and the HTTP server at domainxyz.dom will see in the requests a host header containing the original URI with short.com in it.

Another way to solve your problem is to set up an HTTP rewrite service on the server at short.com that will rewrite URLs to have the hostname domainxyz.com. In nginx it will be something like:

server {
  server_name short.com www.short.com;

  location / {
    rewrite (.*) http://www.domainxyz.com$1 permanent;

I do not know anything about configuring this with apache's mod_rewrite or lighttpd but I believe this is also possible with them.

share|improve this answer
I just came across this question today and I see this answer also makes a misleading suggestion which is actually incorrect, and as the accepted answer that may mislead other readers somewhat. –  Greg A. Woods Sep 1 at 18:25
Thanks for updating! CNAMEs can only be used for 3rd level domains and longer ones. –  timurb yesterday
The level is irrelevant -- CNAMES can only be used for domains where absolutely no other resource records are used. –  Greg A. Woods yesterday
You can either use A or CNAME -- I think this was in my initial posting. What I was missing is you can't use CNAMEs for 2nd level domains.Thank you for correcting me in this! –  timurb 7 hours ago
The level is irrelevant -- anywhere any other records are required, such as where an SOA and NS records are required, there cannot be a CNAME. An SOA and NS records are not always at the second level -- take for example example.co.uk where the SOA would be at the third level. –  Greg A. Woods 7 hours ago

In addition to what Erthad has said, you can also accomplish this using pound - a reverse proxy and load-balancer - using the "Redirect" configuration.

share|improve this answer
Pound looks pretty intense. Just a shame I can't use it on MediaTemple ;) but thank you for your suggestion! –  Jack Jun 16 '10 at 9:09
You are welcome! –  sybreon Jun 18 '10 at 17:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.