title: Struggling to have .htaccess redirect on failed login
body: <p>What I'm hoping to achieve is fairly simple. I have a development folder on the root of the web server which I do not want people to access without a login. If they visit a page under development and do not have a login (or try to login and fail), the .htaccess file should redirect them to an error page which in turn redirects to the homepage on a delay.</p>
  
  <p>I'm using two .htaccess files to achieve this, one on the root which reads:</p>
  
  <pre><code>ErrorDocument 400 /error.php
  ErrorDocument 401 /error.php
  ErrorDocument 403 /error.php
  ErrorDocument 404 /error.php
  ErrorDocument 500 /error.php
  </code></pre>
  
  <p>and one in the root of the development folder which reads:</p>
  
  <pre><code>AuthType Basic
  AuthName "Development Area"
  AuthUserFile /home/content/44/7545744/html/_dev/.htpasswd
  Require valid-user
  </code></pre>
  
  <p>error.php is hopefully styled like the rest of the site and the content informs the user of what type of error they experienced and contains a meta redirect.</p>
  
  <p>Now, this works fine if you're already on the site and try to go to the development folder, however, if you are clicking a link to the development folder before being on the live site first and close the login window, it pops right back up at least 5 more times before showing the error page without styles.</p>
  
  <p>If you'd like to see a live demo, visit <a href="http://ionnursing.com" rel="nofollow">ionnursing.com</a>, then add <a href="http://www.ionnursing.com/_dev" rel="nofollow">/_dev/</a> to the URL. If you exit the login window, you can see the desired effect, an error page displays and after ten seconds, redirects you to the homepage. However, Google Ion Nursing and select one of the many links to the _dev folder. The login window displays multiple times before redirecting you to the error page.</p>
  
  <p>I don't have very much experience with .htaccess files, so I'm guessing I'm doing something wrong. Any guidance would be appreciated.</p>
  
  <p>I've already added a robots.txt file telling crawlers to ignore the _dev folder, however, I really need the redirect to work until search engines update.</p>