Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Question: How can I use .htaccess for subdomains
Old 08-15-2007, 12:56 PM Question: How can I use .htaccess for subdomains
goheadtry's Avatar
Webmaster Talker

Posts: 730
Name: John
Location: United States of America, California
Trades: 0
How can I use .htaccess for subdomains?


Hi I would like to make it so that

technologyforever.com/kx3/
becomes
kx3.technologyforever.com

How can this be done?
__________________
Free $1 gift card when you signup at
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
 
Register now for full access!
Old 08-15-2007, 01:08 PM Re: Question: How can I use .htaccess for subdomains
Skilled Talker

Posts: 62
Name: Daniel
Trades: 0
as in, if someone types in kx3.technologyforever.com it reads from ....com/kx3?
castis is offline
Reply With Quote
View Public Profile
 
Old 08-15-2007, 02:03 PM Re: Question: How can I use .htaccess for subdomains
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
I found a tutorial just for this:

http://www.vbulletin.org/forum/showthread.php?t=155054
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 08-15-2007, 03:10 PM Re: Question: How can I use .htaccess for subdomains
goheadtry's Avatar
Webmaster Talker

Posts: 730
Name: John
Location: United States of America, California
Trades: 0
Quote:
Originally Posted by mgraphic View Post
I can't see the code it says something about a license
__________________
Free $1 gift card when you signup at
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
Old 08-15-2007, 03:50 PM Re: Question: How can I use .htaccess for subdomains
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Sorry . . . .

Quote:
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
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 08-15-2007, 05:21 PM Re: Question: How can I use .htaccess for subdomains
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
* 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

Warning, doing just that will have no effect !!!

DNS files have a serial ID, that is used to tell the other DSN server which version of the zone is served, without thos extra servers to download it.
If you just change that line and don't update the id, the modification will only be valid for PC that uses your DNS server as default for their connections.
Look at this random zone file, I've put the serial number in bold.
The serial number is formated as "year month day number", without spaces.
So, for today, it would start like 200708151 for the first modification, then 200708152 for the second, and so on...
Code:
 ;
 ; Zone file for debuntu.foo
 ;
 ; The full zone file
 ;
 $TTL 3D
 @       IN      SOA     ns.debuntu.foo. chantra.debuntu.foo. (
                         200608081       ; serial, todays date + todays serial #
                         8H              ; refresh, seconds
                         2H              ; retry, seconds
                         4W              ; expire, seconds
                         1D )            ; minimum, seconds
 ;
                 NS      ns              ; Inet Address of name server
                 MX      10 mail         ; Primary Mail Exchanger
                 MX      20 mail2        ; Secondary Mail Exchanger
 ;
 ns              A       192.168.1.5
 www             CNAME   www.debuntu.org.
 ftp             CNAME   ns
 gw              A       192.168.1.1
                 TXT     "Network gateway"
 mail            A       192.168.1.2
 mail2           CNAME   otherbox
 otherbox         A      192.168.1.3
                 TXT     "Otherbox"
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to Question: How can I use .htaccess for subdomains
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24203 seconds with 12 queries