Automatic subdomain for every directory (mod_rewrite)

Discussion in 'Installation/Configuration' started by xsoft, Aug 16, 2013.

  1. xsoft

    xsoft New Member

    Simple question and nowhere is an answer.

    I want to have automatic subdomain creation (ISPadmin 3.0.3).
    I mean whenever I create a directory, a subdomain will be created.


    Code: -> /var/www/ -> /var/www/ -> /var/www/ -> /srv/web/ -> /srv/web/
    I dont want to use ISPadmin > Sites > Sudomain for website. Im migrating 9 domain and one have like 200 subdomains. Also create subdomain ad a directory is much faster for me and it works well on previous hosting (no, I dont have configuration fro there).

    ISPadmin > Sites > Website > Auto-Subdomain (none, www, *.) doesnt helped.

    Im looking for something like mod%rewrite solution since no ISPadmin option is avaliable.
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^sub.domain.tld [NC]
    RewriteRule ^/(.*)$ /sub/$1 [L]

    but for * (not static domain) and > www redirection.

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www
    RewriteRule (.*) http://www.%{HTTP_HOST}$1 [L,R]

    Web root:
    here usually index.htm is.


    /www (new rood folder for and
    /<any_folder> (for <any_folder>

    Simple enough?
    Any help of how to do this? Thanks you.

    PS: I have DNS setup (*,A,CNAME. Every * ends on my server)
    Last edited: Aug 16, 2013
  2. xsoft

    xsoft New Member

    Hmm hmm hmm ... done.

    # presmeruj na
    RewriteRule !^/www - [C]
    RewriteCond %{HTTP_HOST} ^(www\.)?iidx\.cz
    RewriteRule ^/(.*) /www/$1 [L]
    # vsechy hod do adresare /xxx
    #RewriteCond %{HTTP_HOST} !^www.* [NC]
    RewriteCond %{HTTP_HOST} ^([^\.]+)\.iidx\.cz
    RewriteCond /srv/www/ -d
    RewriteRule ^(.*) /%1/$1 [L]

Share This Page