Devine Posted July 29, 2007 Share Posted July 29, 2007 Is there a way to create a subdomain via php? (Without creating a new host account via whm access) Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/ Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 This really isn't a php issue. Something like... RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.yoursite\.com RewriteCond %{HTTP_HOST} ([^.]+)\.yoursite\.com [NC] RewriteRule ^(.*)$ http://www.yoursite.com/%1 [L,R] In your .htaccess will redirect http://foo.yoursite.com to http://yoursite.com/foo. So now, all you need do is have php create the foo (mkdir) directory within your web root. Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310128 Share on other sites More sharing options...
Devine Posted July 29, 2007 Author Share Posted July 29, 2007 Ok, how about.. a) How can I create a folder and insert certain files within that folder? b) How can I turn that folder into a subdomain access via php? Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310132 Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 a) mkdir, fwrite. b) See above. Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310136 Share on other sites More sharing options...
Devine Posted July 29, 2007 Author Share Posted July 29, 2007 for the mkdir, should I write the path as "www/folder" ? Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310142 Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 Would depend on your setup. Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310147 Share on other sites More sharing options...
Devine Posted July 29, 2007 Author Share Posted July 29, 2007 nvm, I looked into it alittle more, thanks for the functions Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310154 Share on other sites More sharing options...
Devine Posted July 29, 2007 Author Share Posted July 29, 2007 One other thing though... whats the function to replace all non-letter/number characters out of a variable? .. I just want to allow the following: "-" "a-z" "numbers" Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310156 Share on other sites More sharing options...
Devine Posted July 29, 2007 Author Share Posted July 29, 2007 This really isn't a php issue. Something like... RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.yoursite\.com RewriteCond %{HTTP_HOST} ([^.]+)\.yoursite\.com [NC] RewriteRule ^(.*)$ http://www.yoursite.com/%1 [L,R] In your .htaccess will redirect http://foo.yoursite.com to http://yoursite.com/foo. So now, all you need do is have php create the foo (mkdir) directory within your web root. This doesnt work. Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310160 Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 This doesnt work. What does that mean? What results are you getting? Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310164 Share on other sites More sharing options...
Devine Posted July 29, 2007 Author Share Posted July 29, 2007 No result.. I go to "http://beta.SITE.com" and it says "page doesnt load".... Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310166 Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 Have you got a directory within your web root called beta? Does it contain an index.php file? Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310167 Share on other sites More sharing options...
Devine Posted July 29, 2007 Author Share Posted July 29, 2007 There is a folder called "beta".. but there arent any files in it.. but should it still show the "parent directory" link and such if so? Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310168 Share on other sites More sharing options...
Devine Posted July 29, 2007 Author Share Posted July 29, 2007 Also, when I try to add any files to the "beta" folder (with SmartFTP)... It says I do not have permission / folder doesn't exist... Is my mkdir ok? function createfolder( $folder ) { $folder = explode( "/" , $folder ); $mkfolder = ''; for( $i=0 ; isset( $folder[$i] ) ; $i++ ) { $mkfolder .= $folder[$i] . '/'; if( !is_dir( $mkfolder ) ) mkdir( "$mkfolder" , 0777); } } Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310169 Share on other sites More sharing options...
Devine Posted July 29, 2007 Author Share Posted July 29, 2007 Also, when I try to add any files to the "beta" folder (with SmartFTP)... It says I do not have permission / folder doesn't exist... Is my mkdir ok? function createfolder( $folder ) { $folder = explode( "/" , $folder ); $mkfolder = ''; for( $i=0 ; isset( $folder[$i] ) ; $i++ ) { $mkfolder .= $folder[$i] . '/'; if( !is_dir( $mkfolder ) ) mkdir( "$mkfolder" , 0777); } } I realize that when I create the folder, it doesn't set the "user" or "group".. Is there a way to do that? Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310171 Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 Also, when I try to add any files to the "beta" folder (with SmartFTP)... It says I do not have permission / folder doesn't exist... If your going to create the directories in php your best to use php for all interactions. This is to do with the fact that ftp runs under your username, while php runs under apache's process username. This can cause qute a few issues on shared hosting. I realize that when I create the folder, it doesn't set the "user" or "group".. Is there a way to do that? chmod. Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310179 Share on other sites More sharing options...
Devine Posted July 29, 2007 Author Share Posted July 29, 2007 Now how about a function in php that can strip a variable of anything that isn't a number or a letter? Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310183 Share on other sites More sharing options...
Devine Posted July 29, 2007 Author Share Posted July 29, 2007 If your going to create the directories in php your best to use php for all interactions. This is to do with the fact that ftp runs under your username, while php runs under apache's process username. This can cause qute a few issues on shared hosting. Is there a way to set the user/group to be my ftp user via php? Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310185 Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 Is there a way to set the user/group to be my ftp user via php? chmod. Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310189 Share on other sites More sharing options...
Devine Posted July 29, 2007 Author Share Posted July 29, 2007 Isn't it chown that can change the user/group? Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310195 Share on other sites More sharing options...
Devine Posted July 29, 2007 Author Share Posted July 29, 2007 Ok, so I'm using lchown now... And I wanted to know what I have to do to make the path "/var/www/html/USER/FOLDER" accessible? help! Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310201 Share on other sites More sharing options...
dj-kenpo Posted July 29, 2007 Share Posted July 29, 2007 most shared hosts disable the ability for subdomains unless you use their panels. simple htaccess won't work Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310263 Share on other sites More sharing options...
Devine Posted July 30, 2007 Author Share Posted July 30, 2007 most shared hosts disable the ability for subdomains unless you use their panels. simple htaccess won't work Well I have a reseller account... so does that help? lol.. But uhh, any ideas? Link to comment https://forums.phpfreaks.com/topic/62329-creating-subdomain/#findComment-310593 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.