Reverse proxy help needed? Make subdomain appear as directory?

Discussion in 'Apache' started by theblade24, Oct 10, 2013.

  1. #1
    Hi,

    I have an ecommerce store.

    dns at godaddy. A record www points to the 3dr party hosted shopping cart solution on ip a.a.a.a

    I also have a blog. A record blog subdomain points to another server b on ip b.b.b.b hosted away from the shopping cart server a completely.

    So www goes one place and blog goes to another.

    The problem is I need to somehow make the blog appear within the main site as www.mydomain.com/blog instead of as a subdomain blog.domain.com.

    I cannot access or modify the hosted shopping cart server in any way. I cannot load wordpress there, that is why it is on a completely separate server.

    I've been told this is perhaps possible with a reverse proxy configuraton on server b where ip b.b.b.b is.

    So that even though blog. points to server b it can appear that the url is www.mydomain.com/blog and the blog pages off that directory as well.

    Can this be done via reverse proxy? Can it be done another way?

    Can someone help me accomplish this hopefully?

    Thanks!
     
    theblade24, Oct 10, 2013 IP
  2. MBDungo

    MBDungo Active Member

    Messages:
    163
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    58
    #2
    You need to have mod_rewrite on your 3rd party-hosting shopping cart solution.
     
    MBDungo, Oct 10, 2013 IP
  3. theblade24

    theblade24 Active Member

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    73
    #3
    Thank you for your help but I believe you've mis-understood the configuration. This answer won't help me. Server B where the wordpress blog is is the one that needs to be configured, not server A anyways.
     
    theblade24, Oct 10, 2013 IP
  4. MBDungo

    MBDungo Active Member

    Messages:
    163
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    58
    #4
    For you to rewrite "www.example.com/blog" into "blog.example.com" you need to have Apache mod_rewrite on the web server who host "www.example.com".
     
    MBDungo, Oct 10, 2013 IP
  5. theblade24

    theblade24 Active Member

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    73
    #5
    You've got it backwards. "blog.example.com" needs to display as "www.example.com/blog"

    And "blog.example.com" is hosted on a different server and ip than "www.example.com"

    This isn't a simple mod_rewrite issue. If they were on the same server with same ip then sure a quick rewrite rule would do it. In this case they are on 2 different servers on 2 different ips in 2 different geographical locations......
     
    theblade24, Oct 10, 2013 IP
  6. theblade24

    theblade24 Active Member

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    73
    #6
    This placed on server B where only blog.example.com resolves

    RewriteCond %{HTTP_HOST} ^(www\.)?example\.com/?$
    RewriteRule ^blog(/.*)$ http://blog.example.com$1 [P]
    ProxyPassReverse / http://blog.example.com/

    will make blog.example.com or anything after it appear as www.example.com/blog or www.example.com/blog/etc etc etc?
     
    theblade24, Oct 10, 2013 IP
  7. MBDungo

    MBDungo Active Member

    Messages:
    163
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    58
    #7
    Try:
    RewriteEngine on
    RewriteBase /
    
    RewriteRule ^(.*)$ http://www.example.com/blog/$1 [P]
    ProxyPassReverse / http://www.example.com/blog/
    Code (markup):
    Or:
    RewriteEngine on
    RewriteBase /
    
    RewriteRule ^(.*)$ http://www.example.com/blog/$1 [P]
    Code (markup):
    I call it super proxy.
     
    MBDungo, Oct 10, 2013 IP
  8. theblade24

    theblade24 Active Member

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    73
    #8
    500 Internal Server Error
     
    theblade24, Oct 10, 2013 IP
  9. MBDungo

    MBDungo Active Member

    Messages:
    163
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    58
    #9
    Please wait a minute before checking it. Also, is your .htaccess file in the root of "blog.example.com"?
     
    MBDungo, Oct 10, 2013 IP