mod_rewrite help - rule to test if index file exists

Discussion in 'Apache' started by adrianTNT, Jan 3, 2010.

  1. #1
    Hello.

    I need some help with mod rewrite, the redirects are more complicated but I will try to simplify a bit...

    I have more domains hosted on a main site's directory.
    Domains on drive are hosted under main site like this:

    /domains/domain1.com/
    /domains/domain2.com/

    I am editing the .htaccess in main site and what I want is the rule to test if file index.php exists in the domain directory, and if not then show content of /domains/index.php

    something like:

    RewriteCond if !file_exists /domains/(THE_DOMAIN)/index.php
    RewriteRule ^domains/([^/]*)/$ /domains/index.php?domain=$1

    How do I write that ?
    Thanks.
     
    adrianTNT, Jan 3, 2010 IP