0

I have a standard WordPress installation at the root of my public_html directory with this .htaccess:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

I would like to protect the directory /manager which contain an other application with AuthType Basic so my .htaccess look like:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]

AuthUserFile .htpasswd
AuthType Basic
AuthName "Admin Area"
Require valid-user

Here is my basic structure:

/.htaccess
/index.php
/manager/.htaccess
/manager/index.php

Now, when I try to access /manager directory, I receive a 404 Not Found from my WordPress installation. Why?

2 Answers2

0

Whenever I have rewriting and password protection enabled I get somme issues like you have got, and adding the folowing two lines to my htaccess file always fix them, try it :

ErrorDocument 401 default
ErrorDocument 403 default

Edit :

Change this line :

RewriteRule ^(.*)$ index.php [QSA,L]

to this :

RewriteRule ^(.*)$ /manager/index.php [QSA,L]
Oussama Jilal
  • 7,669
  • 2
  • 30
  • 53
0

You will need to alter your .htaccess in the root to remove the directory /manager from the rewrite rules used by WordPress (which handles everything through index.php)

So you need to add a new rewrite condition in like so;

# BEGIN WordPress

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.php$ - [L]

  RewriteCond %{REQUEST_URI} !^/( manager|manager/.*)$
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
</IfModule>

# END WordPress
Oussama Jilal
  • 7,669
  • 2
  • 30
  • 53
McNab
  • 6,767
  • 4
  • 35
  • 55