Search code examples
network-programmingxamppportforwarding

External Access to localhost Xampp files


I am using no-ip for generating a domain name .

I have already set-up port-forwarding(I am using D-link) and it is successfully forwarding to localhost.(http://localhost)

But I would want it to forward to a file in htdocs in xampp folder. something like http://localhost/folder/file.php

how to configure this???


Solution

  • Try this. You need this to be your index file in your htdocs folder.

    <?php
        if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
            $uri = 'https://';
        } else {
            $uri = 'http://';
        }
        $uri .= $_SERVER['HTTP_HOST'];
        header('Location: '.$uri.'/folder/file.php');
        exit;
    ?>