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?
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]
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.