1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

mod_rewrite all subdomains to one directory.

Discussion in 'Apache' started by mokeyhead, Feb 27, 2009.

  1. #1
    I am a newbie on the whole mod_rewrite so any help would be greatly appreciated!

    The functionality I need is:

    www.mydomain.com >> needs to point to a top level dir ( mydir/www/docs/ )
    --This is setup as virtual server in apache and is fine.

    all_subdomains.mydomain.com >> need to all point to only one specific sub dir ( mydir/www/docs/all_subdomainsgohere )
    -- I have wildcard subdomains set up in DNS and ServerAlias *.mydomain.com

    I can get the rewrite workinging initially with an .htaccess in mydir/www/docs/:

    RewriteCond %{HTTP_HOST} ^[^.]+\.mydomain\.com$ [NC]
    RewriteRule ^$ /all_subdomainsgohere/ [L]


    BUT when my page code starts trying to load in other directories from here: mydir/www/docs/all_subdomainsgohere
    I get page not found errors.

    So if my index page trys to redirect to all_subdomains.mydomain.com/login/index.html

    This doesn't work, I assume it is looking in the top level directory but am unsure how to correct...

    Can anyone can shed some light on this?

    Thanks
    Michael
     
    mokeyhead, Feb 27, 2009 IP