My apache home server listens for HTTP requests on an alternate port (port 8080), but I would like to let users type my domain name (example.com) without having to specify the port.

So far I've accomplished this through my DNS provider who redirects any requests to www.example.com or example.com to http://123.456.789.001:8080

This is a problem because though it works, users get an ugly number in their URL bar. What I would like to do is rewrite 123.456.789.001:8080 to example.com

I've tried reading http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html, but I'm no expert at URL writing and what I've come up with (and which obviously doesn't work) is:

RewriteEngine on
RewriteCond %{HTTP_HOST} =123.456.789.001
RewriteRule ^(.*) example.com/$1

which I placed in my httpd.conf file.

  • 1
    Why not just run apache on default port 80? if you have already another server listening on port 80, you can install a run proxy server which will receive the requests and forward them to the appropriate server. More details can be provided if you provide more details. – Khaled Feb 4 '12 at 9:28
  • My ISP blocks incoming port 80 requests so I have to run on an alternate port (however they do not forbid hosting a webserver) – Dennis Feb 4 '12 at 11:22

In your situation, you can't achieve what you want. There is 3 solutions (in order of "goodness").

  1. Ask your ISP to open port 80.

  2. Get a server somewhere and configure it with a reverse proxy (with Apache or something else).

  3. Instead of a redirection, use a frame to "encapsulate" your page.

  • that's disappointing... 1. Not happening. 2. Don't have the resources for that 3. Tried it but every single link on example.com shows up as example.com (for instance 123.456.789.001:8080/some/other/location.html shows up as example.com) – Dennis Feb 4 '12 at 16:30

You cannot show a fake hostname or port in the client address bar.

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.