Password Protection with htaccess with Yii Framework

I’m trying to protect my website with a username and password.

This is my .htaccess before adding the Password Protection

 RewriteEngine on

 # if a directory or a file exists, use it directly
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 # otherwise forward it to index.php
 RewriteRule . index.php

I have added the following code at the end of the file

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

So my .htaccess is currently
RewriteEngine on

 # if a directory or a file exists, use it directly
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 # otherwise forward it to index.php
 RewriteRule . index.php

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

The password protection is working fine, but the website returns Internal Error 500

enter image description here

Why is the Password Protection cancels the RewriteEngine part? please advise.


Source: .htaccess

Leave a Reply