create subdomains with forwarding api

Discussion in 'Installation/Configuration' started by bryxal, Aug 14, 2006.

  1. bryxal

    bryxal New Member

    Good day,

    I was wondering if there was a function i could call with the parameters (in PHP) or the general what i need to do to be able to create subdomains with folder forwarding.

    Thanks!
     
  2. sjau

    sjau Local Meanie Moderator

    Can you explain what exactely you need?
     
  3. falko

    falko Super Moderator ISPConfig Developer

  4. bryxal

    bryxal New Member

    Falko, that is exactly it BUT i want to be able to do it in PHP (in my php pages i should say), either by dabling in the ISP config tables or by importing some files and using the functions to add them.

    basically i want to write a script that will create me a subdomain when X event happens and so on.
     
  5. sjau

    sjau Local Meanie Moderator

    if its just subdomains couldn't you use then mod_rewrite?

    sub.domain.com --> domain.com/sub or domain.com/script.php?sd=sub ?
     
  6. bryxal

    bryxal New Member

    A very valiant proposition. Just wondering if this would work in the sense of not having a A-name record, when test.example.com is looked-up in the dns would it not "fail" if i dont have a dns record set up and am only relying on the mod rewrite? i may be completely off base tho
     
  7. sjau

    sjau Local Meanie Moderator

    You can create a wildcard entry for the subs and point it to the domain or your IP in the dns...
    Code:
    *.domain.com.      IN  A    1.2.3.4
    
    Then in the apache config create something like this:
    Code:
        DocumentRoot /www/domain/html
        ServerName www.domain.com
        ServerAlias *.domain.com
    
    And then you only need a .htaccess with rewriting... something like this should work
    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
    RewriteCond %{HTTP_HOST} ^a(.*)-01\.domain\.com [NC]
    RewriteRule ^(.*) /A%1/$1 [L]
    
     
    Last edited: Aug 15, 2006

Share This Page