Q:

Using htaccess to redirect host urls but not when they contain paths or parameters

What I would like to do is use htaccess to redirect (301, Permanent Redirect) simple host only urls to another domain but only when the url contains no path or parameters.
For example:
http://www.mydomain.com should redirect to http://www.myotherdomain.com and 
http://mydomain.com should redirect to http://myotherdomain.com
(which I have found plenty of examples for)
but a url like: 
http://www.mydomain.com/someimage.jpg or http://mydomain.com/js/coolJsScript.js should not be redirected at all.
Any help would be greatly appreciated!
Thanks!

A:

I think this rule will match incoming URLs without any path:
RewriteRule ^$ http://othersite.com/ [L,R=301]

You haven't stated exactly what you are trying to do here, but there might be an alternative, which is to check to see if a file exists, and redirect to your other site if it doesn't exist. This test would be something like
# Check if file exists
RewriteCond %{REQUEST_URI} -f

# it exists, so stop processing
RewriteRule .* - [L]

# Redirect everything else
RewriteRule (.*) http://othersite.com/$1 [L,R=301]

