Follow up to resolved 301 redirect question

Hello,

I found the following post on your site that describes how to redirect a subfolder from domain A to the root of domain B

I have already done exactly this and it works properly, but I would like to take it one step further and get rid of Machine A altogether. i.e. This solutions assumes that Machine A / Domain A / Webserver A is sticking around (this is where the redirect rules are).

To summarize:

1). I have an Apache Webserver running on Machine A with a site that looks like http://domain-A/subfolder/
2). I have another Apache Webserver running on Machine B with a site that looks like http://domain-B/

The 301 redirect on Machine A looks like:

RewriteEngine on
Redirect 301 /subfolder/ http://Domain-B/

Everything works great.

Q. How to I move these rules to Machine B / Webserver B so that I can get rid of Machine A altogether?

Additional info:

I. Machine B is the exact same site with a new domain name (and without the subfolder). The only reason I’ve kept Machine A around is to handle the redirects. There are still quite a few links out there that still point to http://Domain-A/subfolder/… and I want them to keep working.

II. Machine A / Webserver A was setup a long time ago based on Dynamic DNS. So, currently I have dynDNS domain name pointed to the dynamic IP for this host.

III. Machine B / Webserver B is a proper Domain Name (no dynamic DNS) with a Fixed IP.

So… what I’m hoping I can do is:

1). In my Dynamic DNS configuration for http://Domain-A, change the IP address to the Fixed IP address for Domain B (i.e. all traffic to http://Domain-A… will now be directed to Machine B)

2). Add rules to .htaccess on Machine B / Webserver B so that URLs that look like http://Domain-A/subfolder/… are redirected to http://Domain-B/

Is this possible? Any help would be appreciated.

Thanks,
Mike.

md,

First, welcome to SitePoint!

Second, your code shows that you’re not aware that Redirect is a part of the mod_alias (Apache core module). Fortunately, you’ve used it correctly despite the lack of need for the RewriteEngine on statement preceding the Redirect statement.

Third, there is no need to change the code as it will also work on Machine B.

Regards,

DK

Hi DK,

Thanks for the quick reply. I did try adding the same code to .htaccess on machine B, but it didn’t work… and I quickly changed things back. I’ll try it again - not so quickly.

Thanks,
miek.

miek,

Redirect 301 /subfolder/ http://Domain-B/

That code is PERFECT to remove subfolder for a URI/URL as it contains all the requisite (and optional) parts, i.e., Redirect, 301 (optional but a good idea), the absolute internal directory and the absolute (external) redirection. Since only the new domain is specified, this code will work on both the old and new servers.

Regards,

DK

Hi DK,

Ok, so I applied the code again on the new server, and everything worksedgreat. The problem was in my firewall config.

Thanks again for your help.

Regards,
Mike.