Everton Mendonça Everton Mendonça - 3 months ago 15
Apache Configuration Question

.htaccess Redirect subfolder to new domain without the subfolder

I need to redirect a site in a sub-folder to another domain, so, inside the sub-folder I put the following .htaccess file:

Redirect 301 / http://www.newdomain.com/


With this, when I access the sub-folder url http://www.olddomain.com/site1 I get redirected to http://www.newdomain.com/site1, but the correct should be http://www.newdomain.com, without the subfolder url.

Answer

Redirect directive automatically appends original path to target. Use RedirectMatch instead in your subfolder:

RedirectMatch 301 / http://www.newdomain.com/

Make sure to clear your browser cache before testing this.