SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Dec 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

    http://www.sitepoint.com/forums/show...-to-new-domain

    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.

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,679
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    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
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Member
    Join Date
    Dec 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,679
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    miek,

    Code:
    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
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  5. #5
    SitePoint Member
    Join Date
    Dec 2012
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •