Many scripts require you tell them the domain name they are running on. For most cases when offline, or http://localhost/ will work. However when you upload, this must change to the real domain name. There are two solutions to this problem:


1) Use the version converter. Usually a script will read the domain name into a variable, that it will use for the rest of the program. Modify to something like this:



#? $domain = '';

$domain = 'http://localhost/'; #?


After the upload this would become:



$domain = ''; #?

#? $domain = 'http://localhost/';




2) Modify the computers hosts file.


The hosts file (without extension) is a text file located:


  • Windows NT/2000/XP: c:\winnt\system32\drivers\etc\hosts
  • Windows 98: c:\windows\hosts


If it does not exists you can create it, by adding just one line like the below.


It's format looks like this:        localhost


What this file does is map IP addresses to host names. Usually it contains only one entry, the above, that tells windows that http://localhost/ is the same as


So what we can do is add another line:


That's what is needed! Now when is called, the server at will be invoked. This can be optiperl's internal server, or any other external server you are using.


icon_idea You can also change the Host from Options / Run or Project options so OptiPerl also can use the new domain in it's requests.


icon_exclaim The first time you call this mapped domain, you might get a window "Connect to" dialog prompting to connect to the internet; Don't connect, just press "Cancel".


icon_exclaim But this line must be removed, when you then connect to the internet or else the real will never be called when you want to!


icon_idea Note also that the mapped domain does not have to only be used for a http protocol. You can map any domain for  that is used for any kind of port. For example, if you are testing a script that uses mySQL, and you connect to your server's mySQL using, then you can map in the hosts file so that your local mySQL server can be used.


icon_exclaim IMPORTANT: Because of the above, if your have mapped a url like, but your FTP address is also (and not something like then while the url is mapped, your will not be able to connect to your real FTP site. This will happen becase for your computer will mean, which also means itself. It will try to connect to an unavailable FTP server.


Automating when testing web sites


You can create a set of tools in OptiPerl to add and remove this line and integrate with the active project.


Add in one of the project's options data fields, like data7 the value


Create a user tool:


Name: Map local IP to project


Parameters: %data7% "<path to hosts>"


To unmap afterwards, create the following user tool:


Name: UnMap local IP to project


Parameters: %data7% "<path to hosts>" and are included in OptiPerl's installation. The <path to hosts> is replaced when OptiPerl is installed depending on your windows version. They add and remove the line:        site


where "site" is the first argument sent to the script.


Top  Previous  Next