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) Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 a) mkdir, fwrite. b) See above. Quote Link to comment 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" ? Quote Link to comment Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 Would depend on your setup. Quote Link to comment 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 Quote Link to comment 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" Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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".... Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment 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); } } Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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! Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.