Everton Mendonça Everton Mendonça - 1 year ago 141
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 Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download