Search code examples
.htaccess.htpasswd

Why I get 500 internal server error when using .htaccess


I am keep getting a 500 internal server error when accessing the folder.

It does come up with a dialog asking to enter username and password.

But once entered 500 internal server error

AuthType Basic
AuthName "Password Protected Area"
AuthUserFile /customers/7/f/d/reedyfordmobilevaletservice.co.uk//httpd.www/admin/.htpasswd
Require valid-user

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

Solution

  • You may change your rule to this:

    RewriteEngine on
    
    RewriteRule ^(?!public/)(.*)$ public/$1 [L,NC]
    

    (?!public/) is negative lookahead to prevent looping.