Exclude subfolder in Codeigniter using htaccess rewriterule

474 Views Asked by At

I'm using following .htaccess code to hide index.php in CodeIgniter.

RewriteBase /
RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
RewriteRule ^.*$ - [E=CWD:%2]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^.*$ %{ENV:CWD}index.php?/$1 [QSA,L]

I've defined a password protected subdirectory [admin] under webroot with index.php as: HTACCESS

AuthName "Secure Area"
AuthType Basic
AuthUserFile "C:\xampp\htdocs\personal\admin\passwd"
require valid-user

But while I try to access admin folder, it is throwing 404 ERROR. Actually, the .htaccess on webroot is overwriting the htaccess in sub-directory.

The .htaccess under sub-directory is working if following line is removed in webroot

RewriteRule ^.*$ %{ENV:CWD}index.php?/$1 [QSA,L]
0

There are 0 best solutions below