vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Programming Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=188)
-   -   [How-to] Unique subdomain for each member profile (https://vborg.vbsupport.ru/showthread.php?t=155054)

coderphp 08-11-2007 10:00 PM

[How-to] Unique subdomain for each member profile
 
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:

http://www.montadaphp.net/attachment...tachmentid=281

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

0tolerance 10-24-2007 10:54 AM

this is a tottally awesome article, im deffinately going to use it!
A big thanks :), this will deffinately aid me.

Zorck 11-06-2007 04:13 PM

wow! excellent article.

Thanks a lot!

meenstreek 06-05-2008 11:35 PM

Thank you very much! This works great ;).

shofolofo 06-13-2008 04:50 AM

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 .

karlm 06-14-2008 11:58 AM

Quote:

Originally Posted by coderphp (Post 1316108)
Demo:
See what this page leads to: coder.montadaphp.net
or this amine.montadaphp.net

Page cannot be found...?

mmoore5553 09-08-2008 11:14 AM

is there a way to have them setup a image gallery ? i would love to do this ?

bharvey42 09-15-2008 05:14 AM

I couldn't get this to work on my VPS

Brandon Sheley 09-15-2008 05:18 AM

I'm going to give this a try on our new forum
thanks!

trigxm 11-07-2008 05:16 PM

Quote:

Originally Posted by bharvey42 (Post 1622433)
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


All times are GMT. The time now is 09:18 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.01494 seconds
  • Memory Usage 1,736KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete