Directing traffic from a domain to a subfolder of another domain

I registered a new domain, but I do not want to set up its own account. Instead I want to direct all traffic going to that domain to a subfolder of another domain.

So basically, if someone goes to ‘newDomain.com’, it should bring them to an index page located at ‘primaryDomain.com/newDomain/’.

I thought I knew how to do this, but apparently I was mistaken.
Does anyone know how I can set this up?

(I have a VPS by the way.)

In your .htaccess/httpd.conf for the new domain

RewriteEngine on
RewriteRule ^(.*)$ http://www.primarydomain.com/newdomain/ [R=301]

That was a fast response!

Can I make it so that people see it as ‘newdomain.com/page.html’ instead of ‘primarydomain.com/newdomain/page.html’?

You can redirect to any URL you want.

Yes, but how can I have the address bar continue to display the URL of the new domain after the redirection.

After it redirects and the page loads, I still want to see ‘newdomain.com’ in the address bar.
(NOT ‘primarydomain.com/newdomain/’)

Oh, you never said that. You can’t do that (easily) with server configuration. The best you can do is frame the other site (plain old HTML <frameset> tags). The original domain will stay in the address bar, and will not change even as links are clicked, even as links to other sites are clicked, and nothing will be bookmarkable.

Aw, I see… So basically what I was trying to do is not even possible. Thanks for letting me know; I might have ended up spending hours trying to figure that out. I guess I’ll just be using absolute URL’s. Shouldn’t be a problem.