Direct domain from 1and1 to DH server

I bought an extra domain from 1and1 and want to direct it to example.com/example on my DH server. I don’t want to just forward it though. I’ve tried playing around with CNAMEs and A Records but I’m lost. Can someone help me out?

Create a new domain in the Dreamhost panel, where the document root is /home/yourusername/example.com/example

Maybe I could have explained my question better. I bought hosting and a domain with Dreamhost. Lets call that domain1. I bought a second domain through 1and1, domain2, that I want to redirect to domain1.com/example. How do I do this? I read about CNAMEs and A Records but I’m not sure how to use them. I go into my admin panel at 1and1 and go to add a CNAME but it says I need an alias. What do I enter there? Or am I way off on how to direct the new domain?

By “redirect”, do you mean change the URL in the process? If no, my suggestion will work fine. If yes, just 301 it through your registrar’s control panel.

By redirect I mean I want the domain to change accordingly when a new page is clicked. So after I direct it, when someone clicks domain1.com/example/page1 it would say domain2.com/page1 whenever someone would click a page. I think its called mirroring, where it appears to have all the files hosted on domain2 when they’re really still on domain1. I don’t want to use just simple forwarding.

domain1.com should host /home/username/domain1.com
domain2.com should host /home/username/domain1.com/example

Unless I’m still misunderstanding you, that should work.

Doing that will have the pages update accordingly and the domain won’t just revert back to domain1.com/example whenever I click past the first page?

I don’t have to use a CNAME or anything? I know how to input the CNAME I just need to know how to create an alias for domain1.com/example.