username.my-domain.tld ----> users.my-domain.tld/~usernam

Using a single web hosting account to host multiple sites

username.my-domain.tld ----> users.my-domain.tld/~usernam

Postby melihme » Sun Jul 16, 2006 1:42 pm

i have two servers.. my-domain.tld point one of them and users.my-domain.tld point the other..

my users have addresses like users.my-domain.tld/~username

i want to redirect "username.my-domain.com" to "users.my-domain.tld/~username"

i added a wilcard DNS entry *.my-domain.tld point to users.my-domain.tld

but i can not write re-write rule..

how can i do_?
melihme
 
Posts: 1
Joined: Sun Jul 16, 2006 1:00 pm

Postby richardk » Mon Jul 17, 2006 5:17 am

Do you have access to the main server configuration (httpd.conf)?

i added a wilcard DNS entry *.my-domain.tld point to users.my-domain.tld

Where do these subdomains go to (which directory) on the server? The same place as users.my-domain.tld?

i want to redirect

A visible redircet? Or an internal rewrite? For an internal rewrite you'll probably need mod_proxy.

In a .htaccess file in the directory where user subdomains end up:
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^(users|www)\.my-domain\.tld$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.my-domain\.tld$ [NC]
RewriteRule ^(.*)$ http://users.my-domain.tld/~%1/$1 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 9 guests

cron