IP address is shown in address bar instead of domain

亡梦爱人 提交于 2020-01-01 12:12:56

问题


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?


回答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!




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/16767624/ip-address-is-shown-in-address-bar-instead-of-domain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!