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)

New User

joined:May 22, 2013
posts: 1
votes: 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)

Senior Member from US 

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

joined:Apr 9, 2011
votes: 551

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)

Junior Member

joined:Apr 6, 2013
votes: 0

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

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members