Let's say I have a domain, www.mydomain.com.
And I ordered a new domain, abc.newdomain.com.

Both domains are hosted in the same ISP, so currently requests to either of those addresses result in the same page being shown.

I want to redirect all requests to abc.newdomain.com to folder /wp so that when users access abc.newdomain.com they would see whatever is inside folder /wp without seeing the URL change.


  1. How can I achieve this using .htaccess?
  2. How can I prevent users from accessing directly /wp directory (meaning that www.mydomain.com/wp would be blocked)?

1 Answer 1


mod_rewrite can do both of those.

For the first, check the host with RewriteCond and write a rule to rewrite it without using the R flag.

For the second, check the host for www.mydomain.com and write a rule that rewrites anything back to itself with a R=404 flag.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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