Htaccess Causes 403

Hi Joe,

Thanks for taking the rant as intended: to drive home the point. Congrats, too, on recognizing the problem and making it a pet peeve of your own!

Should ever be used? Yes, but only if you are a code developer for others who may not have mod_rewrite enabled. IMHO, in that case, it’s okay but should ONLY be included AFTER a test is made and a 500 error is thrown for unrecognized mod_rewrite code (that would be the result on a server without mod_rewrite and mod_rewrite code in the .htaccess file). In short, comment out any in code you receive, run a text and be ready to uncomment if a 500 error is received. Thanks for allowing me to explain more fully.

Questions:

  1. Correct! Of course, mod_rewrite’s job is to change the {REQUEST_URI} string and, if 301’d, display that change, too.

  2. Correct again! However, think of RewriteRule as the redirection associated with a BLOCK of code which can include 0 - {hopefully few) RewriteCond statements which will be ANDed (or ORed) with the trailing RewriteRule.

  3. Correct! However, the NC flag in a RewriteRule can MISdirect because of incorrect caplitalization (mod_speling is designed to eliminate that problem but is rarely available on production servers). Therefore, my recommendation is to ONLY use NC with {HTTP_HOST} variables.

  4. Correct again (four for four)! mod_rewrite redirections are 302 (temporary) by default so, IF you want to display internal redirections (absolute or relative), then the 301 is required. Of course, not so with external redirections as you stated.

Your treatment of the trailing / for directories leaves me cold. Okay, I rely on Apache to add the trailing slash (technically, it’s incorrect to remove it and “silly” to add it back … which Apache would do for you) AND, if not done correctly (as you ARE doing - albeit I would use the {IS_SUBREQ} rather than creating another Apache variable to do the same thing), it could make your relative links point to the wrong subdirectory level. On the other hand, “if it ain’t broke, don’t fix it!”

The log raises a couple of questions:

  1. If the .htaccess shown in the DocumentRoot?

  2. Directory structure - is fourm a subdirectory (and NOT a file) in the DocumentRoot?

  3. I believe 403 is an “access not allowed” code so that implies an incorrect permission set within the forum.

Regards,

DK