IP address is shown in address bar instead of domain

37,112

Solution 1

Yes you should do away with the redirect and instead create an "A record". The sub-domain entry would typically be, but is not restricted to "www". The record type "A" and destination/target would be your external IP address. Once you update this record it may take several hours before you notice it taking effecting, upon where on people typing your URL would be directed to your web server.

You will need to forward port 80 on your router to the server hosting WAMP.

Finally the WAMP server should be provided with your domain name so it knows which site to load. If use the VirtualHost file this will allow you to host multiple domains on your web server. To do this...

Uncomment the following line so it appears like below in your Apache httpd.conf, to allow Apache to use virutal hosts

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

Then locate the httpd-vhosts.conf file, should be found in your WAMP installation location, such as C:\wamp\bin\apache\apache*version_number*\conf\extra\

Add an entry for your site, altering the details to your own domain name and website location.

<VirtualHost *:80>
ServerName www.stackoverflow.com
ServerAlias stackoverflow.com
DocumentRoot "C:/websites/stackoverflow/"
ErrorLog "C:/websites/stackoverflow/logs/error.log"
CustomLog "C:/websites/stackoverflow/logs/access.log" common
</VirtualHost>

Now restart your WAMP server and give it a whirl.

Tip: If your server won't start after these changes, check that you have created the folder structure for the log files!

Solution 2

Use Forward with masking where you registered your domain. mine is GoDaddy. in the forward settings, you will see this at bottom of the page. click Forward with masking and add the title you want them to see in the address bar of the browser when they go to your site. instead of showing your IP address

Solution 3

Solution described here could resolve this issue.

Most of the free dynamic dns providers, allow acquiring more than one free host name. If allowed you can solve the problem by getting a second name, e.g., mysite2.somefree.org. Now, go and configure your free domain names in the dashboard of free provider in the following way (assume your IP is 188.165.15.29 and your server's listening to port 8085).

  • redirect mysite1.somefree.org to mysite2.somefree.org:8085
  • redirect mysite2.somefree.org to your dynamic IP, say, to 188.165.15.29

This also works when you are using Apache httpd server alone, not being part of WAMP. You do not need to tweak virtual host or any part of your server. You only configure inbound direction.

Share:
37,112
Cains
Author by

Cains

Updated on October 09, 2021

Comments

  • Cains
    Cains over 2 years

    I have a WAMP home web server up and running on a static IP and registered a domain with Namecheap, but I'm a bit shaky with DNS. At first I used URL Redirect and pointed it to my IP. This meant that when you typed in the domain (like example.com) it just redirected you right to my IP, replacing the domain name with it in the address bar. Now I'm trying to get the domain to show instead of the IP in the address bar, which I'm struggling to understand exactly how to do.

    The latest thing I've tried which many people say to do is instead of using URL Redirect to use the A (Address) record type and point it to my IP, which I thought would finally fix my problems. Of course after 15 min or so when it all got updated I'm getting a 400 Bad Request with nginx under it in Firefox, and a blank page in Chrome. Now I'm getting blank pages in both. Did I do something wrong here? Do I need to edit something on the web server such as httpd.conf? Am I going at this completely wrong?

  • Cains
    Cains almost 11 years
    I also posted this on Namecheap, where my domain is registered, and their response was similar to yours (other than editing my hosts file), and for the most part it works. Unfortunately while mydomain.net works, www.mydomain.net gives a blank page. A records for mydomain.net and www.mydomain.net are created for my external IP. link is my hosts file, and link is my VH setup.
  • robert_longworth
    robert_longworth almost 11 years
    You shouldn't really need to edit your HOSTS file, this will only effect your PC locally, not for external user. If you only want this locally then there was no need to even purchase a domain! If you are wanting it to be visible to the outside world then don't touch the host file, instead create a DNS A record... DNS will then resolve to the correct location. Then open port 80 (port forward) on your router to ensure visitors get directed to the webserver itself. If you only want to do it locally you can just add an additonal line to your HOSTS file for WWW. ps vhosts file looks fine :)
  • Cains
    Cains almost 11 years
    Many of the articles I've seen on vhost have been for local setups rather than domains so that probably caused that confusion, thanks for clearing it up. With DNS A records for mydomain.net and www.mydomain.net pointing to my IP and that vhost setup I have the problem of mydomain.net working fine and www.mydomain.net turning up a blank page. Any idea why this would be? I'm really stumped. For now I just have www.mydomain.net redirecting to mydomain.net but I'd prefer to not do it this way.