[How-to] Unique subdomain for each member profile
by
13 Aug 2007
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: http://coder.montadaphp.net or this http://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 http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download.html): Code:
pico /usr/local/apache/conf/httpd.conf Search for something like that: Where you should replace: Code:
ServerAlias montadaphp.net www.montadaphp.net Code:
ServerAlias montadaphp.net www.montadaphp.net *.montadaphp.net * Then execute this command in Shell window: Code:
pico /var/named/montadaphp.net.db Code:
*.montadaphp.net. IN A 66.66.66.66 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] Done waiting for comments and questions Regards Mahmoud |
Similar Mods
Profile Gallery: Allow Users to Upload Member Profile Images | vBulletin 3.6 Add-ons |