473,890 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create subdomain(s) dynamically for user registration?

13 New Member
When each new user tries to register, a directory on the server will create for her/him. (www.example.co m/user_name)
but as you know I need her/him directory to be available as follows too (http://user_name.examp le.com/).

I have Linux Server.It's not a local project, so the _conf file of Apache Server may not accessible at all. I need a working .htaccess code etc. or something else.
Sep 27 '09 #1
7 5541
Dormilich
8,658 Recognized Expert Moderator Expert
look at the mod_rewrite cheat sheet. it's one of the examples there.
Sep 27 '09 #2
Markus
6,050 Recognized Expert Expert
Hm, I strongly doubt you can do that without having access to the server configuration.
Sep 27 '09 #3
Dormilich
8,658 Recognized Expert Moderator Expert
.htaccess can do it. (I know because I use it)
Sep 27 '09 #4
Markus
6,050 Recognized Expert Expert
@Dormilich
Care to give an example? I looked through that link you supplied, but couldn't find anything on 'faking' a subdomain.
Sep 27 '09 #5
TheServant
1,168 Recognized Expert Top Contributor
I found this a while back, but never tried it out:
Expand|Select|Wrap|Line Numbers
  1. RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com$
  2. RewriteRule .* http://domain.com/somescript.php?var=%1 [R,L]
The reason I didn't try it out is because "you need to set up foo.domain.com' s DNS entry to go to your server's IP address. Also you need your server properly configured to show the contents of domain.com's DocumentRoot when foo.domain.com is requested." - Sounded like work, but I might give it another go now that I know more. Let us know how you go!
Sep 28 '09 #6
Markus
6,050 Recognized Expert Expert
@TheServant
Which requires access to the server configuration.

Mark.
Sep 28 '09 #7
dragosXI
1 New Member
hello - I found this thread and I search do to something similar
so I want to show online users that I get them from xml source and it show like that
Expand|Select|Wrap|Line Numbers
  1. <?
  2.     default :
  3.         $xml_source = 'http://www.site.com/xml/users.xml';
  4.         $site_url = 'http://www.site.com/users/';
  5.  
  6. // ---- if we got some data, then try to parse it
  7. if ( $xml_content = file_get_contents( $xml_source ) ) {
  8.  
  9.     $xml_parser = xml_parser_create();
  10.     xml_parse_into_struct( $xml_parser, $xml_content, $value, $full_index);
  11.     xml_parser_free( $xml_parser );
  12.  
  13.  
  14.     $items = array();
  15.     foreach ( $value as $current_value ) {
  16.         if ( $current_value['level'] == 3 ) {
  17.             $items[] = $current_value;
  18.         }
  19.     }
  20.     reset( $items );
  21.  
  22.  
  23.     $item_count = count( $items );
  24.     $users = array();
  25.     for ( $i = 0; $i < $item_count; $i += 2 ) {
  26.  
  27.         $current_user_name = each( $items );
  28.         $current_category = each( $items );
  29.         $users[ strtolower( $current_category['value']['value'] ) ][] = $current_user_name['value']['value'];
  30.  
  31.     }
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.     // ---- If we got category parameter, then show just that part of the array
  39.     if ( isset( $_GET['category'] ) && !empty( $_GET['category'] ) && isset( $users[ strtolower( $_GET['category'] ) ] ) ) {
  40.         $category = $_GET['category'];
  41.     }
  42.  
  43.     if ( $category !== null ) {
  44.         $category = strtolower( $category );
  45.         $new_users = $users[ $category ];
  46.         $users = array();
  47.         $users[ $category ] = $new_users;
  48.     }
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.     // ------- OUTPUT
  57.     if ( $table_output ) {
  58.  
  59.         // ---- how many users should be in one column
  60.         if ( $users_count = count_users( $users ) ) {
  61.             $max_rows = ceil( $users_count / 7 );
  62.         } else {
  63.             $max_rows = 0;
  64.         }
  65.  
  66.  
  67.         echo '<table width="100%" cellspacing="0" cellpadding="0" border="0">' . "\n";
  68.         echo '    <tr>' . "\n";
  69.         echo '        <td valign="top">' . "\n";
  70.  
  71.     }
  72.  
  73.  
  74.     $current_user_number = 0;
  75.     foreach ( $users as $current_category => $users_in_category ) {
  76.         sort( $users_in_category );
  77.  
  78.         // ---- in "table_output" mode we don't need category name.
  79.         if ( ! $table_output ) {
  80.             // ---- Print category name
  81.             echo $current_category . ' (' . count( $users_in_category ) . ')<br>' . "\n";
  82.         }
  83.  
  84.         foreach ( $users_in_category as $current_user ) {
  85.  
  86.             if ( $table_output ) {
  87.  
  88.                 // ---- if the user count is bigger than the allowed number in one column, then we break the list into a new column
  89.                 if ( $current_user_number > $max_rows ) {
  90.                     $current_user_number = 0;
  91.  
  92.                     echo '</td>' . "\n";
  93.                     echo '<td valign="top">' . "\n";
  94.  
  95.                 }
  96.  
  97.             }
  98.  
  99.             echo '<a href="' . $site_url . '' . $current_user . '" ><span class="user_name">' . $current_user . '</span></a>' . "\n";
  100.             if ( $show_category_name ) {
  101.                 echo '&nbsp;<span class="user_category">' . $current_category . '</span>';
  102.             }
  103.             echo '<br>';
  104.  
  105.             // ---- increase user count in the current column
  106.             $current_user_number++;
  107.  
  108.         }
  109.  
  110.     }
  111.  
  112.  
  113.     if ( $table_output ) {
  114.  
  115.         echo '        </td>' . "\n";
  116.         echo '    </tr>' . "\n";
  117.         echo '</table>' . "\n";
  118.  
  119.     }
  120.  
  121. } else {
  122.  
  123.     echo 'Error while trying to open the XML file.';
  124.  
  125. }
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. /**
  134.  * Count all the users in the users array
  135.  *
  136.  * @param array $users_array
  137.  * @return int
  138.  */
  139. function count_users( $users_array ) {
  140.  
  141.     $ret = 0;
  142.     if ( is_array( $users_array ) && count( $users_array ) > 0 ) {
  143.  
  144.         foreach ( $users_array as $current_category => $users ) {
  145.             $ret += count( $users );
  146.         }
  147.  
  148.     }
  149.  
  150.     return $ret;
  151.  
  152. }
  153.  
  154.  
  155. ?>
this will show online users like

http:// www . site.com/users/user-name

and I want to show the online users like

http:// user-name.site.com

Can anyone help me sort this out ?

thank you
Oct 14 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
11114
by: Susan Bricker | last post by:
Hi. I have a routine (BldEmail) that is causing an error on my user's PC but not on mine. HELP!!! I have to fix this tonight. She reports an error with err.number=429 and the error message "ActiveX Component can't create object" out of my BldEmail routine. The routine is called to dynamically build an email note and put it in the Drafts folder. It uses late binding and has the following code: Dim objOutlook As Object
8
2583
by: Paw | last post by:
Greetings. I use asp. what I need is is when a visitor comes to the site, I need it to check the host name. if "www.hometowndigest.com" is the host, then check a folder named "something" and if the folder does not exsist, create folder "www" and then copy folder "temp" and its contents. If the folder "www" is there, look in it, check to see if the files in folder "temp" are in there, if not, copy the files that are not from folder...
3
2149
by: Maximus | last post by:
I have a registration form, when after registering, the user would get a subdomain http://username.domainname.com I created a wildcard DNS which happened to redirect *.domainname.com to the public_html folder. I need to find a way to redirect eahc subdomain to it's user folder.
0
1222
by: anj.smart | last post by:
Hi:-I have my own webspace www.domain.com. When any new user register on to my site, a new url name www.subdomain.domain.com or www.domain.subdomain.com should be provided to it. I want to provide sub-domain name in the above form and then they will be stored in the MS-SQL database with relation to ASP.net Please help me with this.
0
1715
by: Greg | last post by:
Is it possible for authentication using asp.net membership to persist from a site to a subdomain? The scenario I want to provide is: User browses to the page somesite.com and logs in. User clicks on link that points to the subdomain demo/somesite.com. Is it possible to retain the authentication information for the subdomain, so that there is no need to log in again?
12
3076
by: Tina | last post by:
Our company domain, say, wombat.com needs to create several subdomains: support, training, and purchase are three of the subdomains needed. So when someone browses to //training.wombat.com they will be directed to the IP we have assigned. I have two questions: 1. how can I do this at design time? 2. how can I do this at run time from my asp.net code? Thanks,
3
33906
by: a2rodger | last post by:
I am using the following function and parse_url() to attempt to grab the subdomain from my sites url function selfURL() { $s = empty($_SERVER) ? '' : ($_SERVER == "on") ? "s" : ""; $protocol = strleft(strtolower($_SERVER), "/").$s; $port = ($_SERVER == "80") ? "" : (":".$_SERVER); return $protocol."://".$_SERVER.$port.$_SERVER; } function strleft($s1, $s2) { return substr($s1, 0, strpos($s1, $s2)); } $url = selfURL(); $uri =...
0
2163
by: devilsjunk | last post by:
Hello Everybody, In my web application I have created an interface where, if any user register then a subdomain will be created with the user name of the user link this manner E.G. :- http://subdomain.domain.com This works fine. Now if any user name contains special character like underscore then the subdomain only takes the character before underscore. For example if I register with devils_acc06 then the created subdomain URL is...
3
2711
by: tariquetuku | last post by:
i want to create a subdomain upon each user registration as user.example.com how it is possible? thanks
0
9970
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9810
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11207
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10794
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10896
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9612
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7153
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6031
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4251
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.