Reputation: 79
I'm not asking for code, but for some tips. I want to create a system, that automatically create a subdomain, for example, after the payment be approved by PayPal, I create a subdomain, such as: stackoverflow.mywebsite.com
<?php
// Ignore this code.
$createSubDomain = 'stackoverflow.mywebsite.com';
$createSubDomain = 'stackoverflow.mywebsite.com';
$createSubDomain = 'stackoverflow.mywebsite.com';
if($craeteSubDomain !== '') { echo "created"; }
?>
Just that. I guess that I can handle with the content after subdomain creation. :)
Thanks,
Upvotes: 2
Views: 108
Reputation: 843
Here is a pretty good guide.
Basically you are going to want to register the *
subdomain to point to your server. Then you need to configure your .htaccess file to handle it.
Your .htaccess file should look something like this:
RewriteCond %{HTTP_HOST} ^yourwebsite\.com $
RewriteCond %{REQUEST_URI} !^/yourwebsite_folder/
RewriteRule (.*) /yourwebsite_folder/$1
RewriteCond %{HTTP_HOST} ^(^.*)\.yourwebsite.com
RewriteCond %{REQUEST_URI} !^/yourwebsite_folder/
RewriteRule (.*) /yourwebsite_folder/$1
If you want to learn more about .htaccess you can look here.
In your php file instead of creating a subdomain you are creating a folder. when people try to load newsub.example.com the .htaccess file points them to example.com/yourwebsite_folder/newsub
Upvotes: 1