Welcome to WebmasterWorld Guest from 54.146.180.94

Forum Moderators: Ocean10000 & incrediBILL & phranque

Multiple domains redirection with url masking?

   
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
11:27 am on Sep 2, 2013 (gmt 0)

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



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)
12:33 pm on Sep 2, 2013 (gmt 0)

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



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?
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month