Hello,

I'm running Drupal 5.3 for my site, MyiStop.com. I have installed Pathauto module and its working smoothly.

Now, my goal is to give my users with a Sub-domain url that points to their profile page. Currently, the users' profile page has the URL http://www.myistop.com/users/username. But, I want it to be http://admin.myistop.com/.

I have enabled Wildcard support in both my DNS Server and Apache Configuration. Request to any sub-domain of my domain is now pointing to my main site. So, I just tried to use mod_rewrite to re-write the URL. I used the following lines in my .htaccess, but i'm getting "500, Internal Server Error".

RewriteCond %{HTTP_HOST} !^www\.myistop\.com [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.myistop\.com [NC]
RewriteRule ^(.*) http://www.myistop.com/?q=users/$1 [L]

Please help me with the mod_rewrite stuff.

Thanks in advance.

R. Kaja Mohideen
- MyiStop.com

Comments

rastarr’s picture

Subscribing - very interested in the outcome and thanks for raising the question

BarisW’s picture

Any updates yet?

Baris Wanschers / Sixcolored
Sixcolored

Baris Wanschers (@BarisW)
Drupal specialist

kajamohideen’s picture

Yes... I got it working...

Use the following mod_rewrite stuff to redirect username.domain.com to www.domain.com/users/username

RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/users/%2/$1 [R,L]

I'm using Pathauto and user profiles are at www.domain.com/users/username

NOTE: In order to make this work, you MUST have enabled Wildcard Support in both your DNS Server and The Apache Configuration.

Assuming your Apache config uses vHosts, your new configuration would look like this:

<virtualhost>
ServerName domain.com:80
ServerAlias *.domain.com
...
..
</virtualhost>

The ServerAlias statement enables Wildcard support for your domain. From now on, your Apache vHost will react on non-existent subdomains.

Try it friends...

R. Kaja Mohideen
MyiStop.com | Revenue Sharing Website | Get Paid to Blog

BarisW’s picture

get Drupal point to the subdomain links instead of the pathauto links?
Do you use a template function for that?

Great work!

Baris Wanschers / Sixcolored

Baris Wanschers (@BarisW)
Drupal specialist