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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.