WordPress and .htaccess problem

This is an old problem has existed for years, but I just encountered it days ago. In short, the symptom is that access to all password protected regular folders will be directed to the 404 page of WordPress, where “regular” means it’s not a WordPress page. I played around with both .htaccess files in my www root directory and in the protected directory, and found it should be caused by something within the Apache itself but I don’t know what exactly the reason is.

Finally I worked it out by asking on Site5′s forum and got the solution from this site. Because I installed WordPress in a sub-directory /blog under my root, so the solution is to modify the index.php file under the root folder from

< ?php
/* Short and sweet */
define('WP_USE_THEMES', true);
require('./blog/wp-blog-header.php');
?>

to

< ?php
/* fix password protected folder access */
$request_filename = $_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'];
$this_dir = dirname(__FILE__).'/';
if($request_filename!=$this_dir && $request_filename!=__FILE__ && (is_file($request_filename) || is_dir($request_filename))) {
  // we are not supposed be here!
    die;
                    }
/* Short and sweet */
define('WP_USE_THEMES', true);
require('./blog/wp-blog-header.php');
?>

After this modification, everything works well now.

Related posts

Leave a comment

0 Comments.

Leave a Reply


[ Ctrl + Enter ]