homepage Welcome to WebmasterWorld Guest from 54.166.122.65
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Multiple domains redirection with url masking?
ixuacu



 
Msg#: 4606732 posted 10:47 am on Sep 2, 2013 (gmt 0)
Hi there,

I´m getting a bit of trouble configuring some redirections.

We have a multisite web for several white-brand customers, apache as front-end and static content server and Tomcat for the dynamic content.

The main site is www.domain.com.
Every customer has a customer.white-domain.com

When someone goes to http://customer.white-domain.com it redirects to http://www.domain.com/app-customer, that works ok.

We want to mask the redirection so if you type http://customer.white-domain.com it shows the content of http://www.domain.com/app-customer but keeping the original customer url.

My code is the following:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)\.white-domain\.com [NC]
RewriteRule /(.*) http://www.domain.com/app-%1 [R,L]

With that i only get the redirection to work, missing the masking.

Thanks in advance!
Joaquín

 

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4606732 posted 11:27 am on Sep 2, 2013 (gmt 0)

welcome to WebmasterWorld, Joaquín!


you can do this with mod_proxy:
http://httpd.apache.org/docs/current/mod/mod_proxy.html [httpd.apache.org]

you can also Use mod_rewrite for Proxying:
http://httpd.apache.org/docs/current/rewrite/proxy.html [httpd.apache.org]
(assuming mod_proxy is enabled)

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4606732 posted 12:33 pm on Sep 2, 2013 (gmt 0)

With that i only get the redirection to work

Darn that mod_rewrite. It insists on doing what you tell it to do, instead of what you want it to do.

[R] flag = redirect. Temporary 302 redirect to be exact. Even without the flag, anything using a full protocol-plus-domain will be a redirect unless you explicitly tell it not to.

If everything lives on the same server it should all work nicely with the [P] flag.

%{HTTP_HOST} ^(.*)\.white-domain\.com

Watch out for that leading .* At a minimum you'd want .+ because otherwise you're allowing for hostnames with leading . Here you probably want \w+ or, if your server prefers, [^.]+

RewriteRule /(.*) http:/ /www.domain.com/app-%1

The %1 came from the subdomain in the last RewriteCond. But what happened to the path of the URL? You captured it, as one would expect, but where does it go?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved