Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.