Can php allow me to create whatever.homepage.com address

Reply

Join Date: Dec 2004
Posts: 2
Reputation: Samantha-girl is an unknown quantity at this point 
Solved Threads: 0
Samantha-girl Samantha-girl is offline Offline
Newbie Poster

Can php allow me to create whatever.homepage.com address

 
0
  #1
Dec 14th, 2004
I want to find out if php can allow me to create whatever.homepage.com using my web address. I want to point the whatever.homepage.com to the folder homepage.com/whatever. Will php allow me to do this? O is there another script that will allow me to do this?
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,041
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 128
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Re: Can php allow me to create whatever.homepage.com address

 
0
  #2
Dec 15th, 2004
In order to do this, your webhost will have to enter a DNS record for the subdomain so that their routers know to point it to your server. Then, you can use either a .htaccess or .cgi file (most likely PHP as well) to redirect the subdomain to a folder of your choice.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2
Reputation: Samantha-girl is an unknown quantity at this point 
Solved Threads: 0
Samantha-girl Samantha-girl is offline Offline
Newbie Poster

Re: Can php allow me to create whatever.homepage.com address

 
0
  #3
Dec 16th, 2004
Well my webhosting company have told me of the DNS subdomain record however that will only point to another domain ie daniweb.homepage.com would point to daniweb.com. What I am trying to do is point daniweb.homepage.com to homepage.com/daniweb/. some one said it could be done via php and I came her to find out before I went off to learn a new script that I might not use.

So what you are telling me is that php cannot help me? yes - no?
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 127
Reputation: ReDuX is an unknown quantity at this point 
Solved Threads: 5
ReDuX's Avatar
ReDuX ReDuX is offline Offline
Junior Poster

Re: Can php allow me to create whatever.homepage.com address

 
0
  #4
Dec 27th, 2004
Yes you can do this.
You can simply redirect users to the correct folder.
There are two ways to do this really. the first is static. i.e. you set up instances of each domain you intend using. The second is dynamic, the script redirects users blindly, depending on whatever they put in as a subdomain. For dynamic redirection wildcards is required on your DNS. If you are using a free dynamic dns for this site, i suggest you check your settings and enable wildcards if applicable.

I must mention that this only works with HTTP1.1 compliant browsers, Some HTTP1.0 do not post the details required to make this work ($HTTP_POST).
Your index.php:
[PHP]
$subdomain = explode(".",$HTTP_HOST);
$default = ("main.php");

/* Static
if($subdomain[0] == "folder1"){
header("Location:http://$HTTP_HOST/folder1/");
}elseif($subdomain[0] == "folder2"){
header("Location:http://$HTTP_HOST/folder2/");
// and so on...
}else{
header("Location:http://$HTTP_HOST/$default");
}
*/

// Dynamic
if(is_dir("$DOCUMENT_ROOT/$subdomain[0]")){
header("Location:http://$HTTP_HOST/$subdomain[0]");
}else{
header("Location:http//$HTTP_HOST/$default");
}
[/PHP]

In the case of dynamic redirection, the script checks to see if the folder exists before forwarding the user to the folder. If it does not, the user is redirected to the default. In this case, domain.com/main.php .

Hope this helps
I'm pink, therefore, im spam.
http://www.vivaci.net - Quality Webhosting
http://gaming.vivaci.net - FAST UK Gaming servers
http://www.getsigned.org - Free Image Uploads
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 1
Reputation: timo is an unknown quantity at this point 
Solved Threads: 0
timo timo is offline Offline
Newbie Poster

Re: Can php allow me to create whatever.homepage.com address

 
0
  #5
Jan 16th, 2005
Originally Posted by ReDuX
Yes you can do this.
You can simply redirect users to the correct folder.
There are two ways to do this really. the first is static. i.e. you set up instances of each domain you intend using. The second is dynamic, the script redirects users blindly, depending on whatever they put in as a subdomain. For dynamic redirection wildcards is required on your DNS. If you are using a free dynamic dns for this site, i suggest you check your settings and enable wildcards if applicable.

I must mention that this only works with HTTP1.1 compliant browsers, Some HTTP1.0 do not post the details required to make this work ($HTTP_POST).
Your index.php:
[PHP]
$subdomain = explode(".",$HTTP_HOST);
$default = ("main.php");

/* Static
if($subdomain[0] == "folder1"){
header("Location:http://$HTTP_HOST/folder1/");
}elseif($subdomain[0] == "folder2"){
header("Location:http://$HTTP_HOST/folder2/");
// and so on...
}else{
header("Location:http://$HTTP_HOST/$default");
}
*/

// Dynamic
if(is_dir("$DOCUMENT_ROOT/$subdomain[0]")){
header("Location:http://$HTTP_HOST/$subdomain[0]");
}else{
header("Location:http//$HTTP_HOST/$default");
}
[/PHP]

In the case of dynamic redirection, the script checks to see if the folder exists before forwarding the user to the folder. If it does not, the user is redirected to the default. In this case, domain.com/main.php .

Hope this helps

I'm just starting out with php and this is exactly what i want to do
however i'm not sure how to impliment the example you give
i.e. does this example run as a script on the default webpage for the domain
(would i put this in domain.com/index.html)
or does the example need to be a .php file that is actioned by a page?

as I said I probably sound like a 1 year old trying to say "dadda" but please help if you can withstand my ignorance

obviously the static way would be best for my to try out
(although i think i can use wildcard for dns, so once i get a clue i might try the dynamic way)
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 127
Reputation: ReDuX is an unknown quantity at this point 
Solved Threads: 5
ReDuX's Avatar
ReDuX ReDuX is offline Offline
Junior Poster

Re: Can php allow me to create whatever.homepage.com address

 
0
  #6
Jan 16th, 2005
That example would be the default 'index.php' page for your domain i.e.
http://www.domain.com/index.php
It will then be run, and depending on the subdomain you requested, it will direct to the page 'main.php' in the subfolder requested.
e.g. requesting the site/page http://pancake.domain.com will direct the users browser to http://www.domain.com/pancake/main.php

Hope that mekes it a little more clear
I'm pink, therefore, im spam.
http://www.vivaci.net - Quality Webhosting
http://gaming.vivaci.net - FAST UK Gaming servers
http://www.getsigned.org - Free Image Uploads
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC