Dynadot โ€” .com Transfer

PHP: Subdomain Creation?

NamecheapNamecheap
Watch

PoorDoggie

Soon to be RICHdoggie!VIP Member
Impact
18
Hi. Is there any way to create new subdomains using php. I know it is possible, but I can't find a tutorial or script anywhere.

If someone could please send me in the direction of a good tutorial it would be most appreciated.

Thanks a lot
Tom:)
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
php by iteself does not create subdomains, why do you say you know it is possable?
Did someone write a dns server in php? Ok, I will agree is is possable, but it is not
probably someone who knows how to do this would pick php to do this. It would require you to leave a php program running, and not just scripts called from the web browser. They are in the DNS as others have shown.

Now, once they are in the dns, they are handed off to the web server, which you can
then have a single php script handle all the requests and determine what domain
they were for.

A redirection site is best done at the level you are talking about (server) with a dedicated address. If you want some help with this pm me.

(ps, I just looked at that class someone posted the reference to, DO NOT USE it...
it use http: and get request and puts the pw in the link, BAD IDEA)
 
0
•••
theparrot, if you were talking to me I never said that PHP could create subdomains.

-------------------

Just give up trying to make PHP do a job that it cannot do and use Cpanel or just direcly edit .htaccess to make a subdomain.
 
0
•••
Ethan said:
theparrot, if you were talking to me I never said that PHP could create subdomains.

-------------------

Just give up trying to make PHP do a job that it cannot do and use Cpanel or just direcly edit .htaccess to make a subdomain.


nope, I was talking to the OP... and for what he wants (a redirection service, I would not do it with cpanel or .htaccess, but rather at the server level, and above the .htaccess hack level also)
 
0
•••
hey, theparrot? you couldn't tell me of a good tutorial or a guide for what you think I should do? thanks

Also. Its very embarassing, but the forum I got the script off, seems to have shut down on me (phpbuilder.com/board). I don't know about you guys, but I seem to get error messages as soon as a database is used.

I know the principal of the .htaccess thing though

I have this code:
Code:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*)/$ /script.php

unfortunately this dosen't work. Now the server its on at the moment is definitely apache (a lot of people say it will work on any server, but its part of the apache coding I thought).

What am I doing wrong?
Thanks
Tom
 
0
•••
PoorDoggie said:
:) glad to be of service mayur!

BTW, because I don't want to have to start a new thread, I will ask here if anyone ca tell me a quick and easy way to create php files and directorys? in php?

basically, someone comes to the site, types in the shorturl they want (www.website.com/#username) and then it creates that directory, with an index.php file? I need to be able to set the content of the php file.

Is this possible, and does anyone know how to do it?

Thanks a lot!
Tom
I dont really recommend to use folders to create a structure for subdomains. I run my own subdomain service at http://3w.se and I use wildcard catch for subdomains and then I catch and check it against a sql database.

However, to create a directory from within PHP you could use this:
function makeDir($directoryName) {
$output = shell_exec("mkdir $directoryname 2>&1");
echo $output; // Outputs the text returned to stdout when the command is executed
$output = shell_exec("cp index.php $directoryname 2>&1");
echo $output; // Outputs the text returned to stdout when the command is executed
}
 
0
•••
Thanks marcuss. I already have established that. I didn't like the idea of making directories and files though as it would eventually take up a lot of space on my server. Also it provides no [easy] way of bringing up all the users using the site.

Thanks though! :)
Tom
 
0
•••
Appraise.net
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy โ€” Live Options
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back