Home apache2 .htaccess redirect subdirectory to domain without including path
Reply: 1

apache2 .htaccess redirect subdirectory to domain without including path

Jack Wild
Jack Wild Published in 2017-11-13 15:23:30Z

I am attempting to redirect a subfolder on an apache2 server to the root of an entirely different domain, without including the path of the folder in the new domain.

So, in mysite.com/folder-1/folder-2 I have a .htaccess file like so:

RedirectMatch 301 / http://a-totally-different-site.com/

This sort of works, but includes the path in the redirect. So, when you visit mysite.com/folder-1/folder-2 it goes to a-totally-different-site.com/folder-1/folder-2

What I wish to happen, is for the subfolder to redirect to the root, so visiting mysite.com/folder-1/folder-2 will go to a-totally-different-site.com

Is this possible with .htaccess? I have tried a few different approaches I found, but none are working.

Dusan Bajic
Dusan Bajic Reply to 2017-11-13 15:46:32Z

Simple rewrite rule should do:

RewriteEngine On
RewriteRule ^ http://a-totally-different-site.com [R=301]
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.306806 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO