WordPress.org

Ready to get started?Download WordPress

Forums

translating server IP address (6 posts)

  1. yankeerudy
    Member
    Posted 4 years ago #

    I set up my MU install on a server IP address while redesigning and migrating an existing site. Once the redesign/migration was completed, I made the appropriate changes to server, DNS, and database to enable the new WordPress MU site.

    Here's the problem... there are several entries in the Google search index that point at the original IP address pages (i.e., http://74.52.2.28/study/accounting/accounting-cycle/general-ledger-accounting/ ) that I'd like to point to the new appropriate page. (The domain should be college-cram.com) When you click on the ip address link, it goes instead to the home page of the MU install.

    Is there a way to force the IP address to translate to the domain on the fly, so I don't lose these search result links?

  2. blirette
    Member
    Posted 4 years ago #

    PHP can do this. Just catch the URL, replace the IP with the DNS and make a header redirect with the appropriate code (something like 301... google it).

    That is if the new page using the same path after the IP... hope it's the case for you! ;)

  3. yankeerudy
    Member
    Posted 4 years ago #

    Thanks for the reply, Blirette.

    By "catch the URL" do you mean using htaccess? Because with the htaccess accompanying the WordPress install, by the time the browser gets to a php page the extra URL stuff has already been stripped out.

  4. blirette
    Member
    Posted 4 years ago #

    Check this out :

    http://php.net/manual/en/reserved.variables.server.php

    You'll have to use something in here (maybe $_SERVER['REQUEST_URL']) to get the URL. Check in it if you see your IP with something like :

    $pos = strpos($mystring, $findme);

    If it's a go, redirect to the other URL :

    header("Location:www.some-other-dns.com/with-the-rest-of-the-url-requested"

    Get the idea?

  5. yankeerudy
    Member
    Posted 4 years ago #

    I understand how that works. Unfortunately, in the order of operations the browser request first passes through .htaccess before getting to a PHP page, and .htaccess itself redirects (and reformats) the IP-URL to the home page of the blog.

    I guess what I'm trying to nail down is a .htaccess oriented solution.

  6. blirette
    Member
    Posted 4 years ago #

    If every IP requests links to the homepage of the MU install, you just have to put this PHP code on that page.

    ... or via htaccess, but I personnaly don't like to use that trick.

    Anyway, hope it works for you!

Topic Closed

This topic has been closed to new replies.

About this Topic