2

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]
hjpotter92
  • 78,589
  • 36
  • 144
  • 183
Sujit Baniya
  • 895
  • 9
  • 27
  • Try with `RewriteCond $1 !^(admin)` before last line in root htaccess. – Tpojka Sep 27 '15 at 01:16
  • `RewriteCond %{REQUEST_URI} !^/(phpmyadmin/.*)$` `ErrorDocument 401 default` `RewriteRule ^.*$ %{ENV:CWD}index.php?/$1 [QSA,L]` This line worked for me – Sujit Baniya Sep 27 '15 at 01:39

0 Answers0