Dynamic Subdomains

Using a single web hosting account to host multiple sites

Postby Krypton » Mon Aug 04, 2008 8:50 pm

This is my final solution which works!

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.tutorialwave\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.tutorialwave\.com$ [NC]
RewriteRule ^$ /user/%2.php [QSA,nc]


Thanks for your help.
Krypton
 
Posts: 8
Joined: Thu Jul 03, 2008 10:25 pm

Postby richardk » Wed Aug 06, 2008 3:04 pm

Replace "nc" with "L". The RewriteRule doesn't match any letters so it doesn't need to be case insensitive.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Falcon » Fri Oct 24, 2008 12:36 am

Hello! i would like something like this as well.

i have something like this:
http://my-site.com/profile.php?lookup=here is the user id

and i want a rewrite mod that will automatically transform that into this:
http://my-name.my-site.com
Falcon
 
Posts: 7
Joined: Thu Oct 23, 2008 3:26 pm

Postby richardk » Fri Oct 24, 2008 11:49 am

richardk.example.com to example.com/profile.php?lookup=1237? then you will need to read How to change a numeric ID into a name/title for changing richardk to 1237.

You will need DNS for the sub domains. The server will need to be configured to send all the sub domain requests to the same place on the server.

For the subdomain to the file part
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com$ [NC]
RewriteRule ^$ /profile.php?lookup=%2 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Falcon » Fri Oct 24, 2008 6:28 pm

richardk wrote:For the subdomain to the file part
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com$ [NC]
RewriteRule ^$ /profile.php?lookup=%2 [QSA,L]


This one works! if i put a name on front of my site-name like this ( http://something.my-site.com ) it will redirect to the first page, and the subdomain name will remain there.

Now how do i acces my virtual sub domain profile ? ( http://my-name.my-site.com )

i have something like this that goes to user profile!

Code: Select all
<a href='".BASEDIR."profile.php?lookup=".$data['user_id']."'>".$data['user_name']."</a>


that means:

Code: Select all
<a href='http://my-site.com/profile.php?lookup=the id'>my user name</a>


now i need something that will redirect me to this:

Code: Select all
<a href='http://my-name.my-site.com'>my user name</a>
Falcon
 
Posts: 7
Joined: Thu Oct 23, 2008 3:26 pm

Postby richardk » Sat Nov 01, 2008 7:18 am

Either
Code: Select all
<a href='"http://" . $data['user_id'] . ".example.com/'>".$data['user_name']."</a>

or
Code: Select all
<a href='"http://" . $data['user_name'] . ".example.com/'>".$data['user_name']."</a>
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Falcon » Sat Nov 01, 2008 12:26 pm

Code: Select all
<a href='"http://" . $data['user_id'] . ".example.com/'>".$data['user_name']."</a>

This one works, redirects me to an user profile. but i don't want an id to be on front of the domain.


Code: Select all
<a href='"http://" . $data['user_name'] . ".example.com/'>".$data['user_name']."</a>

This one works, but it doesn't redirect me to an user profile just goes to the first page!
Falcon
 
Posts: 7
Joined: Thu Oct 23, 2008 3:26 pm

Postby richardk » Sat Nov 01, 2008 3:23 pm

richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Previous

Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 15 guests

cron