Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > Programming Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
[How-to] Unique subdomain for each member profile
coderphp's Avatar
coderphp
Join Date: Nov 2006
Posts: 204

 

Egypt
Show Printable Version Email this Page Subscription
coderphp coderphp is offline 08-11-2007, 10:00 PM

Hi All

As for Blogs and Free hosting websites we see every user in the website given a unique subdomain, something like user.example.com, Did you ever wonder how this is done? Is the webmaster waiting for new users to activate their sub-domain manually, of course not this must be done automatically, infact automagically
in the following lines you will be learned how to do that in your website.
WARNING: The following tutorial (in Step 1) contains some slight configuration with the webserver, you should ask your webhost to do them for you, or, if you have priviliges to the server be cautious or you will put yourself in endless problems
Again if you dont know how to do that ask for a pro to do it for you.

NOTE:
1- montadaphp.net is to be replaced with your Domain name allover the tutorial.
2- 66.66.66.66 is to be replaced by your website IP (either Shared or Dedicated) allover this tutorial.


Demo:
See what this page leads to: coder.montadaphp.net
or this amine.montadaphp.net


Step 1: Server configuration:
NOTE: be sure to take a backup of the files:
/var/named/montadaphp.net.db
/usr/local/apache/conf/httpd.conf

* Execute this command using your Shell program (you can download one HERE):
Code:
pico /usr/local/apache/conf/httpd.conf
Note that the path of the file may vary accoring to ur system or config, if you dont find the file in the specified path use the command (locate httpd.conf) to find the right path for you.

Search for something like that:



Where you should replace:
Code:
ServerAlias montadaphp.net www.montadaphp.net
with:
Code:
ServerAlias montadaphp.net www.montadaphp.net *.montadaphp.net
then save the file and Close..


* Then execute this command in Shell window:
Code:
pico /var/named/montadaphp.net.db
Add the following line anywhere in the file:
Code:
*.montadaphp.net. IN A 66.66.66.66
Save and close the file
Restart your Named & httpd services
or restart the whole webserver


Step 2: Writing .htaccess file to redirect subdomains:
Create a new file named .htaccess or edit ur existing file (if there is one) and add the following code:
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^(.+)\.montadaphp\.net
RewriteRule ^(.*) http://www.montadaphp.net/member.php?username=%1 [R=301,L]
and upload it to your forum's root (usually public_html)

Done
waiting for comments and questions
Regards
Mahmoud
Reply With Quote
  #2  
Old 10-24-2007, 10:54 AM
0tolerance 0tolerance is offline
 
Join Date: Jun 2007
Posts: 88
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

this is a tottally awesome article, im deffinately going to use it!
A big thanks , this will deffinately aid me.
Reply With Quote
  #3  
Old 11-06-2007, 04:13 PM
Zorck Zorck is offline
 
Join Date: Jan 2003
Posts: 43
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

wow! excellent article.

Thanks a lot!
Reply With Quote
  #4  
Old 06-05-2008, 11:35 PM
meenstreek meenstreek is offline
 
Join Date: Jun 2007
Location: Sydney, Australia
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you very much! This works great .
Reply With Quote
  #5  
Old 06-13-2008, 04:50 AM
shofolofo shofolofo is offline
 
Join Date: Aug 2007
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the great article

but i have a couple of questions :
Is there a way to do this via cpanel?
as i'm not comfortable with editing server's configs .

does it have cn immediate effect?
as when i try to create a custom subdomain in cpanel it tells me that it requires some time to be activated as it will be published over DNS servers .
Reply With Quote
  #6  
Old 06-14-2008, 11:58 AM
karlm's Avatar
karlm karlm is offline
 
Join Date: Jul 2006
Location: England
Posts: 447
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by coderphp View Post
Demo:
See what this page leads to: coder.montadaphp.net
or this amine.montadaphp.net
Page cannot be found...?
Reply With Quote
  #7  
Old 09-08-2008, 11:14 AM
mmoore5553 mmoore5553 is offline
 
Join Date: Aug 2008
Posts: 530
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

is there a way to have them setup a image gallery ? i would love to do this ?
Reply With Quote
  #8  
Old 09-15-2008, 05:14 AM
bharvey42 bharvey42 is offline
 
Join Date: Jan 2002
Posts: 180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I couldn't get this to work on my VPS
Reply With Quote
  #9  
Old 09-15-2008, 05:18 AM
Brandon Sheley's Avatar
Brandon Sheley Brandon Sheley is offline
 
Join Date: Mar 2005
Location: Google Kansas
Posts: 4,678
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm going to give this a try on our new forum
thanks!
Reply With Quote
  #10  
Old 11-07-2008, 05:16 PM
trigxm trigxm is offline
 
Join Date: Nov 2008
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by bharvey42 View Post
I couldn't get this to work on my VPS
If your running Plesk, you'll have to put the information in

VHOST_TLD/conf/httpd.conf
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:48 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08378 seconds
  • Memory Usage 2,291KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (6)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete