Forum Moderators: phranque

Message Too Old, No Replies

Mod rewrite redirect for subdomains, but.

not making use of sub-domains.

         

Mr Bo Jangles

8:30 am on Mar 21, 2006 (gmt 0)

10+ Year Member



Hi all,
Real newbie here, and I would like some help with this.

I want to offer users for my web program, their own subdomain to my site - without my setting up any subdomains - i.e. I want to redirect each 'dummy' subdomain to a particular real address.
For example:

www.yourcompany.mywebsoftware.com gets redirected to:
www.mywebsoftware.com/application2879

OR

www.yourcompany2.mywebsoftware.com gets redirected to:
www.mywebsoftware.com/application3782

Basically what I want to do is allow clients to be able to choose their subdomain name, and then all I have to do is put a new entry in my .htaccess file and it will redirect it to where I want on my server(but it will NOT be a subdomain).

Thanks for any assistance,

jdMorgan

8:38 pm on Mar 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> all I have to do is put a new entry in my .htaccess file

Understand that this kind of solution scales very poorly. Because there are no lexical similarities between the account name and the account number, you'll need to use either one rule per account, or use RewriteMap -- either for a direct table lookup, or to call a script/database to look up the related account using MySQL or similar.

You might just want to look into Apache mod_userdir -- it's a lot simpler.

Jim

Mr Bo Jangles

8:11 am on Mar 22, 2006 (gmt 0)

10+ Year Member



Thanks Jim,
When you say it 'scales very poorly' - can you give me an indication of the implications?
I understand that there would be one rule for each client - but I may only have 25 or so clients on the one server - would that present a problem in the server actioning that rewrite file?

Would the mod_userdir let me achieve exactly what I want - when I looked that up, the examples given didn't indicate to me that it would do what I wanted....The examples given indicated that the directory accessed could be changed, leaving the suffix of the address the same - I kinda want the reverse.

<snip>

[edited by: jdMorgan at 2:37 pm (utc) on Mar. 22, 2006]
[edit reason] Please use Commercial Exchange forum to post job offers. [/edit]

jdMorgan

2:44 pm on Mar 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The code is quite simple, but you'll need a copy of the ruleset for each customer if the relationship between the customer subdomain and customer subdirectory name does ot follow any particular pattern. Once you've got 25 customer-subdomain rulesets being processed for each and every HTTP request to your server, performance may start to decrease if you're getting 100,000 unique visitors per day.

Options +FollowSymlinks
RewriteEngine On
# Once copy of the following per customer, with subdomain and paths modified to suit.
RewriteCond %{REQUEST_URI}!^/customer_files/
RewriteCond %{HTTP_HOST} ^customer_subdomain\.example\.com
RewriteRule (.*) /customer_files/$1 [L]

Jim

Mr Bo Jangles

4:28 pm on Mar 22, 2006 (gmt 0)

10+ Year Member



Many thanks Jim - I'll give it a whirl.