2

I am trying to redirect from a subdomain, to a certian port, like sub1.domain.com redirects to domain.com:1337. But directly, not through a webpage. I'm making a java program to connect to the subdomain and the socket connect like this Socket --> sub1.domain.com --> domain.com:1337 with no page inbetween. Just like this post.

Also, If I add this to my httpd config

<VirtualHost *:80>
    Servername sub1.domain.com
    redirect / http://domain.com:1337/
</VirtualHost>

It connects to the website but gets the html of a redirect page, not the serverside connection.

Community
  • 1
  • 1
Spencer H
  • 450
  • 1
  • 6
  • 17

1 Answers1

3

What you're trying to do, can be accomplished with the mod_proxy directives. You should use that instead of redirect. Something like:

<VirtualHost *:80>
  ServerName sub1.domain.com
  ProxyPass / http://domain.com:1337/
  ProxyPassReverse / http://domain.com:1337/
  ProxyPreserveHost On
</VirtualHost>
Andres Olarte
  • 4,380
  • 3
  • 24
  • 45
  • It doesn't work. There isn't an error or anything, but wamp doesn't change from orange to green. I checked the error log too. – Spencer H Nov 06 '12 at 22:47
  • You'll have to provide more details of what you're trying to do, and what exactly you're seeing. You should setup the most basic configuration (which would probably be without apache). After the basic config works, then try to add apache into the mix. – Andres Olarte Nov 07 '12 at 15:39
  • It's exactly like this post http://stackoverflow.com/questions/12183112/redirect-non-http-traffic-to-a-port-based-on-a-subdomain – Spencer H Nov 08 '12 at 19:31
  • in my opinion this is the best solution because the URL in the browser will stay as the original url for example `http://sub1.domain.com/` instead of changing to `http://domain.com:1337/` (if using `Redirect`) – wired00 Sep 20 '14 at 16:48