Do you have access to any error logs? Even in your CPanel? Often that will show what the result of the rewrite was and can help you figure out what is wrong.
You shouldn't need rewrite engine on more than once. I would remove the bot rewrites until you get this sorted just in case it is interfering. I am not sure if it is worth the trouble.
Thanks for the response, Paul. Actually, I posted this in another forum, and have got it fixed now. I think part of this was due to the fact that the directory I was testing is a password protected dir, and thus it was being thrown off.
Here's what I've got now, which works:
RewriteEngine on
Rewritecond %{http_host} ^mydomain.com [nc]
RewriteRule ^.*$ http://www.mydomain.com%{REQUEST_URI} [R=301,L]
Hey guys,
I've just added a .htaccess file to my website today for the first time. I'm doing quite a bit of work and research on SEO for the first time in a long time (ever?) and am learning quite a bit. Anyway, one thing I wanted to do was redirect requests coming for http://domain.com TO http://www.mydomain.com.
It is working. To an extent.
Since I have uploaded the .htaccess file, every time I go to http://domain.com/directory, I am taken to my 404 Error Page (But, of course, when I go to http://www.domain.com/directory, I am taken to where I want to go).
My culprit lies somewhere in here, at the top of my .htaccess file. I copied pretty much all of this code from some tutorials, etc... I've read on the internet.
<Files .htaccess>
order allow,deny
deny from all
</Files>
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^mydomain.com [nc]
rewriterule ^(.*)$ http://www.mydomain.com/$1 [r=301,nc]
ErrorDocument 404 /error404.php
By the way, do I need to run "RewriteEngine on" everytime I want to "rewrite" something? For example, I read a tutorial that gave some code to prevent a lot of the well known "black" bots from gaining access to my website. I decided to go ahead and include that. So underneath the last line you see here, I have "RewriteEngine on" again, and a LOT of rewritecond, checking to see if the bot should have permission or not.
Here's the first and last line of that:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
etc... etc... etc...
RewriteRule ^.* - [F,L]
IT consulting, Technical Support, and Web Hosting Solutions
http://www.huntsources.com - Hunting Resources