Jump to content

Need some help on making subdomains on the go!


ipwnzphp

Recommended Posts

I fount this tut on webhostingfreaks and it dont seem to work all that good. Can anyone help out here?

 

1. Set up an error document in your .htaccess file that redirects every single 404 to a file called maybe redirection.php

2. Add a wildcard DNS record in your zone files, so that [whateverhere].yourdomain.com points to the domain IP.

3. Add a wildcard serveralias in your apache configs by using:
ServerAlias *.yourdomain.com

4. Write the following code in your redirection.php file

<?
$url=$_SERVER["REQUEST_URL"];
$newurl=str_replace(".yourdomain.com","",$url);
$newcomplete="http://yourdomain.com/".$newurl;
Header("Location: ".$newcomplete);
?>

So when someone enters a subdomain, let's say myself.yourdomain.com they get redirected to yourdomain.com/myself.

 

 

Iam trying to say like if somone goes to http://www.username.mysite.com it will pull the id form this link user_system/profile.php?pg=view&id=1114 on the $_GET['id'] do a mysql than pull the username back and then make the subdomain.

It's not possible. The subdomain has to be created before it can be accessed. You could create the subdomain when the user registers though. I believe cPanel has some sort of API which you can use for this, but I think you need access to it's WHM to use it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.