.htaccess Problems
Hey guys,
I've just added a .htaccess file to my website for the first time a couple days ago. 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. Here's what I've got:
<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]
Hey guys,
I've just added a .htaccess file to my website for the first time a couple days ago. 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. Here's what I've got:
<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]









