.htaccess redirect to sub-domains

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

.htaccess redirect to sub-domains

Post by alex.barylski »

We have several folders in a web site like:

Code: Select all

domain.com/members
domain.com/register
domain.com/login
Currently these directories physically exist and simply have an .htaccess file in each one that does something like:

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} !^members\.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{REQUEST_URI} ^/member($|/.*$)
RewriteRule ^.* http://members.domain.com%1 [R=permanent,L]
Is there any way to merge all of these directories .htaccess files into the single root .htaccess file?
User avatar
LanceEh
Forum Commoner
Posts: 46
Joined: Tue Feb 17, 2009 11:53 am
Location: Florida

Re: .htaccess redirect to sub-domains

Post by LanceEh »

You could try doing regex pattern matching, and then transpose that to the

http://%1.domain.com

I haven't done this for a subdomain so proceed at your own risk, this is only a guess!

Take care.
Post Reply