homepage Welcome to WebmasterWorld Guest from 54.226.230.76
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
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:4606734
 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




msg:4606737
 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




msg:4606745
 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