Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

MOD REWRITE Subdomain to RootDomain Folder

Is it possible to use MOD REWRITE to rewrite URLS from a subdomain to root?



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

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?


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

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

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.


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

Featured Threads

Hot Threads This Week

Hot Threads This Month