LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   mod_rewrite: redirect depending on subdomain (http://www.linuxquestions.org/questions/linux-server-73/mod_rewrite-redirect-depending-on-subdomain-573478/)

mysql_connect 07-30-2007 02:50 PM

mod_rewrite: redirect depending on subdomain
 
Any idea how do I redirect depending on subdomain, for example:

domain.com
www.domain.com

I want them to redirect to www.domain.com/mainpage and:

customer1.domain.com
customer2.domain.com
.
.
.
etc

redirected to www.domain.com/customers.

rizhun 08-01-2007 06:23 AM

I'm no re-write pro, but try something like:

Code:

RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 9

RewriteCond    %{HTTP_HOST}      ^www\.domain\.com$
RewriteCond    %{HTTP_HOST}      ^domain\.com$
RewriteRule    ^(.+)              http://www.domain.com/mainpage  [NE,L,R]

RewriteCond    %{HTTP_HOST}      ^www\.customer(.+)\.domain\.com$
RewriteCond    %{HTTP_HOST}      ^customer(.+)\.domain\.com$
RewriteRule    ^(.+)              http://www.domain.com/customers  [NE,L,R]

Then you can have a look at the rewrite.log and figure the rest out.

Hope this helps.


All times are GMT -5. The time now is 01:46 PM.