February 19th, 2013, 12:04 PM
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.
February 19th, 2013, 01:24 PM
You can use $_SERVER["HTTP_HOST"] to get the domain name that the site is being accessed as.
February 19th, 2013, 07:21 PM
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.
February 20th, 2013, 03:23 AM
use rewrite rules
use rewrite rules, add it in .htaccess file and put that file in your wordpress folder.
February 20th, 2013, 07:56 AM
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.
February 21st, 2013, 01:42 AM
Yes, you need to rewrite the rules and just add it to .htaccess file and place it in your root folder.
February 21st, 2013, 06:11 AM
$-SERVER["HTTP-HOST"] -use this to get the domain name.