Introduction: Setting Up Subdomains on HTTP Alternate Ports (8080)

About: Master student in Computer Science & Information Engineering, one of the developer of ArOZ Online Project. I love making something no one has thought of. If you like making things that seems not possible, send…

Recently, I bought myself a domain and I want to set up sub-domains for my web server. However, my server is running on Port 8080 which is not a standard port for HTML protocol and it is not possible to set up a sub-domain in the normal way. In this instructable, I will share the way to remove the port number in the url bar of your browser and add javascript based virtual sub-domains system to your web server.

Step 1: Network Configuration

The reason for my special web server port was due to another web server running in my local network which has already occupied the port 80 and I have no access to that server. Hence, to host my website on another server (or PC), I have to use a different port (Port 8080).

Step 2: Domain Setup

First, you have to buy your domain name. The one I am using is provided by In the Host Setting, you can choose "Port 80 Redirect". This will make the domain name you type in (e.g. be directed to your real ip address(e.g. 123.456.789.10:8080) with the use of

Step 3: Check the Result of Port Redirect After Your Setting Has Been Applied

After 5 - 10 minute, your setting should be updated and the iframe div should be added to your web page when you enter your domain name in your browser URL bar as shown in the picture.

Step 4: Create Files and Folders in Your "www" Folder

As I was using WAMP Server as my web server, my web server's root folder was in C:/wamp/www. You can read more on "how to install wamp" on the following instructable. Here

  1. Create a folder for your sub domain.If you want to use, just create a folder call "download" inside your root folder.
  2. Create a php named as "subdomains.php", the javascript will be placed inside this php
  3. Create an index.php or rename your index.html to index.php if you already have your own index.

Step 5: Edit the Subdomains.php

Open the subdomains.php with text editor. I use wordpad++ here for the example. You can download the zip file provided and change all the "" inside to your own domain name. The javascript works as follow:

  1. Check if the url in your browser URL bar contains
  2. If yes, get the part of string between the "http://" and ""
  3. Redirect you to the new url: ""

For example, if you enter, the javascript will try to redirect you to


On line 20 and 21 of the zipped subdomain.php, you can choose either keeping the URL in your browser URL bar unchanged ( or update the URL in your browser URL bar to ""

Step 6: Modify Index.php to Include the New Javascript

Open your index with wordpad++ or other text editor.

Add <?php include "subdomains.php"; ?> after <head> as shown in the picture.

Step 7: Done

Now, you can type in (subdomain).(yourdomain) and the javascript will automatically redirect you to (yourdomain)/(subdomain).

Example: -> ->

Step 8: IMUS Laboratory

This system was a by-product of the development of IMUS Online System.

No update or improvement will be made to this code as the development of sub domains redirection system was terminated by our laboratory. Use with your own risk.

Free to share and modify. If you have any question, feel free to comment below and I will reply as soon as I read your comment.