简体   繁体   中英

How could I make my website open in a specific port?

I own a website which is hosted on my windows machine. I have all the necessary software installed,like apache,php etc... I have created a sub-domain in freedns.afraid.org and I am using this instead of my IP. I have port forwarded on port 8080 so the page index.php will be shown only if someone open the website on port 8080 If someone open the website on port 80,which is the default,the page he will see is this: http://prntscr.com/b7sttk but if he add in the address bar after the domain the :8080 he will see this: http://prntscr.com/b7su47 which is what I want the visitors to see. So now the question,how could I make the website open automatically on port 8080 without typing every time (for example) domain.e-it.gr :8080 Is that possible? Thanks in advance! :)

you need to add a file index.php with :

 <?php 
$actual_link = "http://$_SERVER[HTTP_HOST]".":8080"."$_SERVER[REQUEST_URI]";
header('Location: '.$actual_link);

?>

this file will redirect to :8080 :)

or just :

<?php 
    $actual_link = "http://$_SERVER[HTTP_HOST]".":8080";
    header('Location: '.$actual_link);

    ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM