Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do you set up the domain (I'm using GoDaddy) to mask the server URL but to append the sub-page link.

I'm thinking something like the Wikipedia en.wikipedia.org/wiki/something (or, if it would require httpd.conf access, setting it to append the default subpage link eg. ?page_id=2)

Currently I can set up the domain to either be masked completely without showing any sub-page links or to simply redirect my domain to my web server.

share|improve this question

migrated from superuser.com Apr 15 '11 at 21:29

This question came from our site for computer enthusiasts and power users.

Do I need to use the CNAME record for this? :> – Halik Apr 15 '11 at 21:48

If I read correctly you want links to sub.domain.com/path to be redirected to domain.com/path and not just domain.com (may have the naked/sub domains the wrong way around but it's the same principle).

Generally this is called a relative redirect and can be done with an Apache rule like:

RewriteEngine on
RewriteRule ^http://sub\.domain\.com(/.*)$ http://domain.com$1 [L,R]

You don't need the L option, it's just stops processing further rules in case something else conflicts, but you need the R (or R=302) to redirect to another domain. You may also want the redirects to be cacheable by setting long distance expiry dates, etc.

If you want the subdomain part to be the path you can use:

RewriteEngine on
RewriteRule ^http://(.*)\.domain\.com(/.*)$ http://domain.com/$1$2 [L,R]
share|improve this answer

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.