.htaccess redirect subdomain to different IP w/Port

Discussion in 'Site & Server Administration' started by no1un0, Jul 26, 2016.

  1. #1
    Ok, there's about an 80+% chance I'm just a walking pile of retard, but I cannot figure out how to get my subdomain redirected to a different IP with a port.

    Here's the details:

    I purchased 'domain.com' from Google, and they have my Zone file:
    A @ 111.222.333.444 3600
    CNAME ftp domain.com 3600
    CNAME www domain.com 3600
    I'm using 000webhost.com for my webhosting, cuz free.

    I edited my .htaccess file, initially, just to test my Index.html (which isn't going to be the primary, just wanted to test):

    RewriteBase /
    DirectoryIndex www/website/index.html

    That worked, no problem.

    At that point, I got cocky. I have a browser-based application I use, and can access remotely (at 22.33.44.55:1234), so I thought "sure...it deserves to have a handy-dandy vanity name, too!". So I created the subdomain at 000webhost.com: 'sub.domain.com'

    Then, I kinda just flailed around a bit, effectively accomplishing nothing more than a headache:
    Attempts 1 & 2:
    • Created an A record for 'sub' to 111.222.333.444
    • Created sub\Index.html:
      • <html>
        <head>
        <meta http-equiv="refresh" content="0; url=22.33.44.55:1234">
        -ALSO TRIED-
        <meta http-equiv="refresh" content="0; url=1234.22.33.44.55">
        </head>
        <body></body>
        </html>
    • Edited the .htaccess file to redirect sub.domain.com to sub\Index.html:
      • RewriteBase /
        DirectoryIndex www/website/Index.html
        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC]
        RewriteRule DirectoryIndex sub/Index.html
    • Result: This ultimately redirected sub.domain.com to 22.33.44.55, but without port 1234 (if I typed sub.domain.com:1234, that worked - but the main point of this is to get rid of typing the port)
    Attempt 3:
    • From Google Domains - created Subdomain Forwarding (301) to 22.33.44.55:1234
    • Result: Well, according to whatsmydns.net, sub.domain.com was resolving to 3-4 different Google IP's, but going to sub.domain.com in my browser didn't take me where I wanted to go.
    Attempt 4:
    • Deleted Subdomain Forwarding, and re-added A record for 'sub' to 111.222.333.444
    • Edited the .htaccess file to redirect sub.domain.com to sub\Index.html:
      • RewriteBase /
        DirectoryIndex www/website/Index.html
        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC]
        RewriteRule ^(.*) "http\:\/\/22\.33\.44\.55\:1234\/$1" [R=301,L]
    • Result: sub.domain.com lands me on a 000webhost.com error/ad page (sub.domain.com:1234 just returns the same 'Can't Reach this Page' browser error)
    Ok, so I realize that was a lot of stuff to read-through (especially if you already know exactly where I missed my left turn at Albuquerque), but I appreciate any reading/analysis/solution that may come from this posting (which, I should also mention - I know I clicked the box above about this being the BEST place for this thread, but...if there's one thing we've probably all learned by this point in this thread, it's that I don't know enough to know whether or not this the best place...or even a good place...for this thread. I'm hoping, so as to not SPAM the wrong forum, and cause extra grief on the mods, but hope's about all I have left at this point)

    Thanks in advance :cool:
     
    Solved! View solution.
    no1un0, Jul 26, 2016 IP
  2. #2
    Hi,

    The following should work (I added in http:// spaces because the post is trying to access the IP)
    <meta http-equiv="refresh" content="0; url= http : / / 22.33.44.55:1234">
     
    Karim Nasser, Jul 27, 2016 IP
  3. no1un0

    no1un0 Greenhorn

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #3
    Oh man...haha As my dad always says "If that was a snake, it woulda bit me." Worked perfect, thanks! :)
     
    no1un0, Jul 28, 2016 IP
  4. Karim Nasser

    Karim Nasser Greenhorn

    Messages:
    34
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    18
    #4
    You're welcome
     
    Karim Nasser, Jul 28, 2016 IP