0

I have a website on WordPress with a responsive theme. It is located on my server hosted by Apache. Everything works well when I access the website with its IP address. The problem is when I try forward my domain to this address.

I have two options on my domain control panel:

  1. Forward example.com on IP address http://192.0.2.1:8080/website Result: When I type example.com in browser I see the example.com URL but the website does not load corectly on smartphones

  2. Forward 301 example.com on IP address http://192.0.2.1:8080/website Result: Type example.com, website loads corectly on mobiles but in url I see http://192.0.2.1:8080/website where I wanted to see example.com

I know that in the first case the problem is that domain forwarding adds iframe to site and that is why the responsive view does not load.

I want to use 301 zforwarding and mask the URL with example.com. How can I achieve this on WordPress?

  • 1
    What you are trying to do does not make sense to me at all! Why are you forwarding a domain name to an IP address when the domain name translates to the IP address? Seems ridiculously redundant. If you need access to port 8080 you can just access it with example.com:8080. – closetnoc Feb 5 '17 at 17:10
  • 1
    "I want to use 301 forwarding and mask url with domain.com." - You can't 301 redirect and mask the URL. You would need to proxy the request (which I doubt that you can from your domain registrar - assuming that is where you are referring to). But why aren't you using DNS (as closetnoc suggests)? Do you specifically want to hide the port and pretend to your users that it's on port 80? – MrWhite Feb 5 '17 at 17:17
  • Do you specifically want to hide the port and pretend to your users that it's on port 80? If this is the case, then a proxy is required. This is not for the faint at heart! For this, you will really need to know what you are doing and secure your system thoroughly. This is not always a simple task. Using a proxy can open your system to significant abuse and and vulnerabilities that you may not be ready for. The proxy you use will depend upon on criteria that will likely make the answer to long for a Q&A format. Whole volumes are written on the highly technical subject. Cheers!! – closetnoc Feb 5 '17 at 17:57
1

There are two possibilities that I am taking from your question so I will cover them both.

Make http://111.111.111.111:8080/website Appear as http://www.domain.com:8080/website
In this instance all you need to do is setup a standard DNS record pointing www.domain.com to your server's IP address. The important thing to note here is that DNS just translates a domain name to an IP address, the port number and file path must be in the address bar as well.

Make http://111.111.111.111:8080/website Appear as http://www.domain.com
In order to make this work you need to setup a proxy server. A proxy server works by translating the URL you are requesting into something else. Commonly used to provide external access into internal company sites (such as allowing you to access intranet.local externally of the local network with the address intranet.domain.com). This would allow you to hide the IP address, port number, and even the site specific path (so that www.domain.com/about/something.html would allow access to http://111.111.111.111:8080/website/about/something.html through the proxy). The difficulty here is securing the proxy environment. A poorly secured proxy server can be a huge security hole into your local network, and can also be used as a launching point to attack or spam other websites and appear as though to be coming from your network. This can get extremely complicated to do and is not for someone without experience in network security and at least an awareness of network protocols. The vastly better solution if possible would be to change the port that serves the HTTP requests from 8080 to port 80 which is the standard HTTP port and so can be ommitted from a HTTP request as no specified port in HTTP is taken to mean port 80.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.