> We also have several other domain names which all point to the same website but retains the domain in the address bar.
I'd suggest you research this point first, as you are essentially creating duplicate content here - Multiple URLs which resolve to the same content, and essentially
multiple sites competing with each other for search ranking and links. Unless you have no other competitors in your market niche, this may not be a very good idea...
If you want to redirect only the root-directory index.php page, and only when it has no query string, then you must test the query string:
# Externally redirect non-blank non-canonical hostname requests to canonical hostname
RewriteCond %{HTTP_HOST} ^([^.]+\.)*otherdomain\. [NC]
RewriteCond %{HTTP_HOST} !^(www\.otherdomain\.org)?$
RewriteRule ^(.*)$ http://www.otherdomain\.org/$1 [R=301,L]
#
# Internally rewrite www.otherdomain.org/index.php requests
# with blank query string to alternate/non-default filepath
RewriteCond %{HTTP_HOST} ^www\.otherdomain\.org$
RewriteCond %{QUERY_STRING} =""
RewriteRule ^index\.php$ http://www.otherdomain.org/newfilepath [L]
All of your hostnames should be canonicalized (as shown) before doing any internal rewrites. Otherwise -again- you create duplicate content issues, and the URLs/sites (for example www- and non-www) can compete with each other and leave you constantly fighting links to the "wrong domain" and incorrect domain listings in search results listings.
If you also wish to rewrite the URL "www.otherdomain/" to "/newfilepath", then you should also add a rule to force the canonical URL on /index.php requests. This rule should be inserted before the domain canonicalization rule:
# Externally redirect requests for "/index.php" to "/" (retaining any query strings)
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.php([?#][^\ ]*)?\ HTTP/
RewriteRule ^index\.php$ http:www.otherdomain.org/ [R=301,L]
and then change the last rule above to
RewriteRule ^$ http://www.otherdomain.org/newfilepath [L]
Jim