#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0

    Wordpress PHP Question


    I am hosting a Wordpress site locally on a webserver that is running Windows Server 2008 on my LAN. The wordpress website needs to be able to be accessed externally using a domain name (ww.somedomain.co) and also internally either using its local server IP address or the domain name. Currently using wordpress it needs to be either or.

    My question is, is there a PHP code that I can use to check to see if the HTTP request to access the website is external or internal? If the request is external, use a certain IP or domain name and if the request is coming from an internal host, use a different IP address.

    I know this is not a clear question. Ask away if you don't understand what i'm asking.
  2. #2
  3. Jealous Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,302
    Rep Power
    9400
    You can use $_SERVER["HTTP_HOST"] to get the domain name that the site is being accessed as.
  4. #3
  5. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    Without a lot of hacking the code it is very difficult to get a WordPress installation to work at more than one host name because the core code is completely written assuming that it will only ever operate at a single host name. The problem goes far beyond just the code, because WordPress also stores full URLs, including the host name, in many places in the database. Even moving WordPress permanently from one host name to another is difficult.

    Your best bet would be to create a hosts file entry locally that maps the external domain to the internal IP of the web server hosting WordPress.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    14
    Rep Power
    0

    use rewrite rules


    use rewrite rules, add it in .htaccess file and put that file in your wordpress folder.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0
    Thanks for the replies. For the time being we just decided to turn on reverse NAT on our network to allow the request to travel back into the our LAN. It seems to be working fine now.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    1
    Rep Power
    0
    Yes, you need to rewrite the rules and just add it to .htaccess file and place it in your root folder.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Location
    Bangalore, India
    Posts
    2
    Rep Power
    0
    $-SERVER["HTTP-HOST"] -use this to get the domain name.

IMN logo majestic logo threadwatch logo seochat tools logo