NameSilo

PHP: Subdomain Creation?

SpaceshipSpaceship
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.
GoDaddyGoDaddy
You can do it if you use CPanel. Let me create the code for it and test it really quick. I will reply here in a few minutes.
 
0
•••
You could use "wildcarded dns" and mod_rewrite, depends on what you require I guess.
 
0
•••
0
•••
0
•••
I'll have a look at the link. Thanks

Um, KodeKing... I do have cpanel at the moment, but in 30 days that will go and I will have to host my site elsewhere and cpanel is not an option at the place I will host it, although if you could still give me the script, so I can have a rough idea of what I need to do? Thanks a lot :)

You could use "wildcarded dns" and mod_rewrite, depends on what you require I guess.
Thanks a lot, I think. Its much apreciated, but I don't know what you mean! :( sorry if I sound thick! :(

Thanks all!
 
0
•••
PoorDoggie said:
Thanks a lot, I think. Its much apreciated, but I don't know what you mean! :( sorry if I sound thick! :(

Thanks all!

Wildcarded DNS is where you have a CNAME record which directs anything.yourdomain.tld to yourdomain.tld basically.

e.g
Code:
*       14400   IN      CNAME   domain.tld.

You'll have to read up on mod_rewrite. if you explain the purpose I can suggest some code or whatnot.
 
0
•••
It's actually pretty easy to do, do you know how to use the PHP function fopen();? If you know how to use the function, it will greatly help you with what you wish to do.
 
0
•••
I recently purchaced a domain redirection site off someone, but it dosen't work, and if it did it would make the domain harder to remember, than the one before it. Basically at the moment if you sign up to the domain redirection (which dosen't work) then you SHOULD get a url like this: www.my-domain-redirection-website.com/?r=#id-no-of-user. I would rather people chose what they wanted, so I am developing a way in which they can have: www.my-domain-redirection-website.com/#username.

What I really want is for people to be able to choose their own sub-domain. This makes it feel more professional, I think. Its better to have your name before the .com!

So someone comes to the site and has a website like: www.geocities.com/members/user029583/tclayson/index.html and wants to shorten it. They type in a box their desired domain name (ie: poordoggie.my-domain-redirection-website.com) and then it automatically makes that subdomain (well, when they click an activation link sent to them in an email... but I can work that out!). I a then going to create a script that all the subdomains link to that finds the first part of the subdomain and gets the... well you know the rest!

Anyway, thats why I want the subdomain script!

Thanks a lot to anyone who helps! :) You are all so helpful!

Tom
 
0
•••
Yeah I get what your trying to do now, basically that script you were using previously was making use of query strings. But you still haven't answered the question previously, do you know how to use the PHP function fopen();?
 
0
•••
oh... yea - I can remember the principal, and with a short look somewhere I'll remember it.

Something like:
Code:
$var = fopen("something/something/that.txt");

:)
 
0
•••
Kool. Some of my friends can use this. I will let them know. Thanks.
 
0
•••
:) 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
 
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

Why not just use mod_rewrite, it's so much easier than dealing with a load of folders and files.

But anyway, you'd need mkdir (or shell_exec, exec or system to issue the `mkdir dir` command), and fopen, fwrite, etc.
 
0
•••
hey Scott, do you know of a tutorial for all this anywhere? or a collective name for what you are explaining? Thanks a lot :)

Tom
 
0
•••
PoorDoggie said:
hey Scott, do you know of a tutorial for all this anywhere? or a collective name for what you are explaining? Thanks a lot :)

Tom

Which one are you refering to? mod_rewrite to mkdir, fopen, fwrite PHP method?
 
0
•••
I was refering to mod_rewrite, but I asked on another forum and I got an answer.

You put a few lines of code into a .htaccess file and then it should work. Not sure how to do it with subdomains, but I can do it with directories, so that if you goto www.domain.com/something then it will redirect you to a php file. It dosen't matter what comes after the domain name.

If there is a same kinda principal with subdomains I would love to hear it. I just found out that the scavengers hosting my website want $5 for every subdomain created, so I would rather if they didn't exist, like the folders don't!

Do you understand what I mean? I hope I've explained it clearly

Thanks a lot :)
Tom
 
0
•••
Tom,

First off, do you have wildcarded DNS enabled? If not, ask your host to set it up. Chances are, if they wanted you to pay $5 for every subdomain setup :o they won't setup wildcarded DNS for ya.

Scott.
 
1
•••
um, I dunno, and I don't think I will be staying with my current host anyway, so it dosen't really matter about the subdomains thing.

Thanks for your help. I will look up some more information on mod_rewrite now that I know about it!

You've been a great help Scott and everyone else! :)

Thanks
Tom
 
0
•••
I don't think that PHP has the power to create a subdomain unless you write to .htaccess. I do believe that it is more server side than what PHP is capable of doing. I've never seen it done except in CPanel, which I don't believe is written in PHP.
 
0
•••
CatchedCatched
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy โ€” Payment Flexibility
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back