Hi pos!
Get ready for some rants as you’ve not looked at other posts and your code has many of the same errors I comment on routinely. :mad:
Okay, WP is greedy with its mod_rewrite code but there is NO EXCUSE for anyone to tell you to add an .htaccess file to every directory! .htaccess is hierarchical so having one in the DocumentRoot means that EVERY directory request will comply with the DocumentRoot’s .htaccess before the ones in the path then the directory the request is made. Shame on whomever it was that told you to add useless files! :mad:
Not Found? If the files exist, even WP’s mod_rewrite will leave them alone; that’s what the RewriteCond %{REQUEST_FILENAME} !-f tells mod_rewrite ("If the requested file does NOT {note the !} exist, then check the directory …
Another PET PEEVE of mine is seeing those who profess to be webmasters include <IfModule>…</IfModule> wrappers in .htaccess files. WHY would any webmaster do that? What it is directing Apache to do is check that mod_rewrite is enabled each and EVERY time a file request is made! How wasteful is that? To me, the professionalism of a webmaster is measured in large part by knowing what his/her code does. By allowing WP’s “noobie protection code” to remain in your .htaccess, you’ve shown that you’re in the “script kiddie” mode, i.e., not understanding the impact of the code you use. REMOVE THOSE WRAPPERS! They slow the server for you AND all those on the shared server with you! :kaioken:
RewriteBase is yet ANOTHER case in point! It’s used to UNDO a mod_alias redirection so mod_rewrite can work on it. WHERE IS YOUR Redirect (or Alias) directive? Not there? Then RewriteBase shouldn’t be there either! :mad:
As for your RewriteRule ^index\.php$ - [L] line, it’s completely absurd as it’s only conceivable function is to eliminate looping with the next RewriteRule - BUT that’s already prevented with the -f conditional statement! Repeating this repetitively is also wasteful! :mad:
Finally, using an absolute redirection in the second RewriteRule will cause Apache to look at the server’s ROOT directory (NOT your DocumentRoot) FIRST for index.php before it looks to your DocumentRoot. Lose the leading /!
Result:
# BEGIN WordPress
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .? index.php [L]
# END WordPress
Please note that I also added a ? to the remaining RewriteRule’s regex to account for the empty URI (http://example.com will fetch example.com’s DocumentRoot’s DirectoryIndex file but the request URI is just not there, is it?). Just covering all the bases!
Okay, now that you feel sufficiently “abused,” please know that this is NOT a personal attack but a learning session for you AND for other members! The problems addressed above are important (IMHO) for a webmaster to KNOW yet I see these same mistakes over and over and … In other words, you’re not the first and will not be the last to make the mistake of leaving WP’s code alone.
If you’ve lasted this long, you will have learned WHY and HOW you should have changed their code. Since my “job” is to help you learn, I will have succeeded! :Partier:
If you have any questions, please ask. Questions will help you understand and, if you have the question, someone else will likely benefit, too!
Regards,
DK