Local URL

app-user

Member
Hello!

Calling a local URL.

It works (when external http server is enabled):

function set_proxy($action) {
$host = '127.0.0.1';
$port = "55777";
$scriptDir = dirname($_SERVER['SCRIPT_NAME']);
$path = ($scriptDir === '/' || $scriptDir === '\\') ? '' : $scriptDir;
$url = 'http://' . $host . ':' . $port . $path . '/set_proxy.php?proxy=' . $action;
...

I disable the external http server and try to do it.

It doesn't work:

$url = "http://heserver/set_proxy.php?proxy=$action";

$url = "https://heserver/set_proxy.php?proxy=$action";

$url = "/set_proxy.php?proxy=$action";

$url = "http://heserver/set_proxy.php?proxy=" . urlencode($action);

$url = "https://heserver/set_proxy.php?proxy=" . urlencode($action);

How can I make the function work without an external http server on port 55777?
 
When the external HTTP server is enabled in ExeOutput for PHP, your application listens on a local port (like 55777), and URLs like http://127.0.0.1:55777/... will work because there is an HTTP server handling those requests.

However, when you disable the external HTTP server, there is no HTTP server running—meaning that URLs such as http://heserver/... or http://127.0.0.1:55777/... will not work. ExeOutput for PHP is then running in "internal server" mode, where PHP files are handled internally and not via a web server listening on a port.

How to call a PHP script internally (without HTTP server):

You should not use http:// or https:// URLs to access scripts within the application. Instead, you should use relative paths or the file:/// protocol, or better, include/require the PHP script directly or perform an internal call.

Solution 1: Direct PHP Include/Require

If you want to execute some PHP code from set_proxy.php, simply include or require it:

Code:
include 'set_proxy.php';

You can pass parameters by setting $_GET values before including:

PHP:
$_GET['proxy'] = $action;
include 'set_proxy.php';

Solution 2: Using ExeOutput's functions

If you need to execute a PHP script and get the result as a string, you can use ExeOutput's RunPHP function from JavaScript or from PHP with the ExeOutput extensions.

Solution 3: Internal AJAX Calls (for browser context)

If you are calling via JavaScript from within your application:
  • Use a relative URL, for example: /set_proxy.php?proxy=yourvalue
  • Make sure set_proxy.php is packed in your ExeOutput project.
  • Use AJAX (XMLHttpRequest, fetch) as you would in a normal website, but without the hostname or protocol.
Code:
fetch('set_proxy.php?proxy=yourvalue')<br>  .then(response =&gt; response.text())<br>  .then(data =&gt; {    // Handle response  });

This works only if the request is handled by ExeOutput's internal PHP engine (not an external HTTP server).
 
Back
Top