Jump to content

Creating Subdomain


Devine

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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