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

    
MOD REWRITE Subdomain to RootDomain Folder
Is it possible to use MOD REWRITE to rewrite URLS from a subdomain to root?
RBusiness




msg:4576633
 6:12 pm on May 22, 2013 (gmt 0)

Hello everyone,

I have a challenge.
My site has a community on "www.example.com/community/" - We found a new community software but they say they we need to use a subdomain to use their software, i.e. the subdomain is masked.

But we really want the community to continue to live at www.example.com/community and not community.example.com

THE QUESTION
So the question is, if we mask our subdomain to their site, can we then use a MOD REWRITE to say

1. Anything that is requested from "community.example.com" instead of showing them this URL, instead, show them "www.example.com/community"
2. It would need to work for all possible pages and folders.

What do you think? Is there an example of how I can do this?

 

lucy24




msg:4576688
 8:48 pm on May 22, 2013 (gmt 0)

Heh. Do you realize you're asking the exact opposite of the usual subdomain question? A subdomain has no physical existence due to unalterable constraints of the three-dimensional universe. So any request for "subdomain.example.com" will involve a rewrite to either some wholly different location or, most commonly, a directory located at example.com/subdomain.

What do they mean by "need to use a subdomain"? A subdomain of their domain or yours? If the default software involves rewriting to community.example.com it should be easy to modify all relevant RewriteRules in the htaccess that comes with the software. But if you're looking at a specific software package with a specific set of rules, I don't want to give generic advice.

Matter of fact, the first thing you'll probably want to do is modify their boilerplate to fit your site. Crystal ball tells me you'll find it jam-packed with <IfModule> envelopes and !-f conditions.

In any case, rewriting from a physical location to a subdirectory and then back to a different physical location makes no sense and is a recipe for disaster. You'll want to change rules, not simply add new ones.

Dideved




msg:4576712
 10:07 pm on May 22, 2013 (gmt 0)

Sounds like a reverse proxy is what you need. See httpd.apache.org/docs/2.4/mod/mod_proxy.html#forwardreverse

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