What I must do is use htaccess to redirect (301, Permanent Redirect) simple host only web addresses to a different domain only once the url consists of no path or parameters.

For instance:

http://www.mydomain.com should redirect to http://www.myotherdomain.com and http://mydomain.com should redirect to http://myotherdomain.com

(which i've found lots of good examples for)

but a url like: http://www.mydomain.com/someimage.jpg or http://mydomain.com/js/coolJsScript.js shouldn't be rerouted whatsoever.

Any help could be greatly appreciated!


I believe this rule will match incoming Web addresses with no path:

RewriteRule ^$ http://othersite.com/ [L,R=301]

You have not mentioned exactly what you're attempting to do here, but there can be an alternate, which would be to determine if your file is available, and redirect for your other site whether it does not exist. This test could be something similar to

# 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]