homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Failed Referrer Report after using 301 Redirect in .htaccess

 12:38 pm on Apr 12, 2011 (gmt 0)

I'm using this 301 Redirect in my .htaccess file which redirects correctly from files in the old folder to the new one:

Redirect 301 /tricks/ /kites/tricks/

example.com/tricks/540.html redirects to example.com/kites/tricks/540.html

but in my log files I'm getting a lot of Failed Referrer errors which show


(two // after 'tricks')

Can anyone explain why I'm getting this?



 4:24 pm on Apr 14, 2011 (gmt 0)

There is no problem with your Redirect directive as you posted it.

Look through your raw server log for instances of requests which may trigger this problem. It's likely that these double slashes are part of the original incoming requests. And such requests are often sent by clients with malicious intent (vulnerability scanners, scrapers, etc.)

If this is not the case, then these problems are likely being caused by mis-typed links (possibly on Web sites other than your own). Use the RewriteRule or RedirectMatch directive instead of Redirect, and simply allow for one or two slashes preceding the requested URL-path, discarding the extras.

Important Note:

In order to prevent many potential difficult-to-correct problems, do not mix the use of RewriteRule with either Redirect or RedirectMatch. Doing so means that you cannot control the execution order of these directives. Code is executed in per-module order, not strictly in the order that you place it in your config or .htaccess files.

Each Apache modules "scans through" your config files, and executes only the directives that it recognizes. The server configuration controls the module execution order, and thus the order of execution of the directives in your config files. Applying your directives out of the intended order can have disastrous effect on the operation and search ranking of your site. For this reason, if your use RewriteRule for anything, use it for everything.

You also want to be sure that across all config and .htaccess files, all external URL-to_URL redirects are invoked before any internal URL-to-filepath rewriting can be invoked.



 4:48 pm on Apr 14, 2011 (gmt 0)

Thanks - I'll trawl through my log files to see if I can find exactly where those requests are coming from.

Thanks for the other info as well. I'd assumed that that the .htaccess file was processed line-by-line if you hadn't told me otherwise.


 8:38 pm on Apr 14, 2011 (gmt 0)

The .htaccess file is processed line by line by mod_access which will use only the directives it understands. The file is then processed by mod_alias and again it will use only the stuff it understands. After that, mod_rewrite will process the file line by line using only what it understands. I mention just those three modules here, but in real life there are at least half a dozen more that will also have a go, and the ordering of the modules might not be exactly as I have described.

As well as being sure that across all config and .htaccess files, all external URL-to-URL redirects are invoked before any internal URL-to-filepath rewriting can be invoked you also need to be sure that for any request that is redirected, there is a maximum of one redirect from original request to final URL. That is, no request should ever result in an unwanted multiple step redirection chain.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved