Forum Moderators: DixonJones
What is confusing is that I have old redirect on htaccess and they are not my top articles based on logs. Awstats is what I am using.
What could it be causing this 302's? Aside from htaccess, just in case I was hacked, are there any place where I can view the causes?
Also, check for the number-one cause of unintentional 302 redirects on Apache -- incorrectly-coded ErrorDocument directives:
Incorrect:
ErrorDocument 404 http://www.example.com/error-404.html
Correct:
ErrorDocument 404 /error-404.html
Including a full URL in an ErrorDocument directive forces a 302 redirect, and the requesting client will not see the correct server status response code -- it will see a 302-Found. This behaviour is clearly documented in the Apache core documentation.
The Live HTTP Headers add-on for Firefox and other Mozilla-based browsers is a good tool to thoroughly check your server response codes.
Jim
AddHandler application/x-httpd-php5 .html
AddHandler application/x-httpd-php5 .htm
<Files 403.shtml>
order allow,deny
allow from all
</Files>
# Redirect /index.htm [mydomain.com...]
RedirectMatch permanent ^/blogs/2006/11/15/webpage/$ [mydomain.com...]
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^subdirectory/webpage1.htm$ "http\:\/\/www\.mydomain\.com\/blogs\/2008\/01\/01\/webpage1\/" [R=301,L]
I have at least 10 "RedirectMatch permanent" and a couple of "RewriteRule"
Thanks
Understand that "Redirect/RedirectMatch" and "RewriteRule" are interpreted by two different Apache modules, mod_alias and mod_rewrite. The order in which those two modules execute is variable, and is determined by the server configuration. Each module scans your .htaccess file and executes the directives that it understands. Therefore your directives are not executed in strict top-to-bottom order, they are executed in per-module order.
However, if you choose to continue to use "Redirect" and "RedirectMatch", then specify either "301" or "Permanent" after the directive, as in
Redirect 301 ^/index\.htm http:/example.com/ If you do not specify "301" or "Permanent" then the redirect is a 302 by default.
BTW, there is no need for the RewriteCond on the RewriteRule you posted above, because as coded, it doesn't actually do anything at all.
Jim