Question

Redirect sub directory to subdomain.subdirectory

Posted June 2, 2021 116 views
Apache

How do I redirect all urls from shop/allpages to shop.domain.com

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi there,

You could use the following .htaccess rule to redirect all URLs to a new domain:

RewriteRule ^shop/?(.*)$ https://shop.domain.com/$1 [R=301,NC,L]

With this rule, if someone visits maindomain.com/shop/product-1 they would get redirected to shop.domain.com/product-1.

Hope that this helps.
Regards,
Bobby